寻找二维三角形的中心?
我得到了一个带有 x 和 y 坐标、旋转变量等的 2D 三角形的结构。 从这些 x 和 y 坐标创建的点,我应该围绕该点绘制一个三角形,并使用旋转变量适当地旋转它。
我熟悉在 OpenGL 中使用 GL_TRIANGLES 绘制三角形。 我的问题是以某种方式提取三角形的中间并在其周围绘制顶点。
编辑:是的,我正在寻找的是质心。
I've been given a struct for a 2D triangle with x and y coordinates, a rotation variable, and so on. From the point created by those x and y coordinates, I am supposed to draw a triangle around the point and rotate it appropriately using the rotation variable.
I'm familiar with drawing triangles in OpenGl with GL_TRIANGLES. My problem is somehow extracting the middle of a triangle and drawing the vertices around it.
edit: Yes, what I am looking for is the centroid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
三角形的中心有不同的“类型”。 详细信息:三角形的中心< /a>. 找到三角形中心的快速方法是对所有点的坐标进行平均。 例如:
找到中心后,您需要绕中心旋转三角形。 为此,请进行平移以使中心位于 (0, 0)。 执行轮换。 现在反转您之前执行的翻译。
There are different "types" of centers of a triangle. Details on: The Centers of a Triangle. A quick method for finding a center of a triangle is to average all your point's coordinates. For example:
When you find the center, you will need to rotate your triangle about the center. To do this, translate so that the center is now at (0, 0). Perform your rotation. Now reverse the translation you performed earlier.
我猜你是说三角形的质心!?
这可以通过 1/3(A + B + C) 轻松计算,其中 A、B 和 C 分别是三角形的点。
如果你有你的点,你可以像往常一样简单地将它们乘以你的旋转矩阵。 希望我没听错。
I guess you mean the centroid of the triangle!?
This can be easily computed by 1/3(A + B + C) where A, B and C are the respective points of the triangle.
If you have your points, you can simply multiply them by your rotation matrix as usual. Hope i got you right.
三角形中有几个点可以被视为其中心(正交中心、质心等)。 维基百科关于三角形的文章的这一部分提供了更多信息。 只需查看图片即可快速了解。
There are several points in a triangle that can be considered to be its center (orthocenter, centroid, etc.). This section of the Wikipedia article on triangles has more information. Just look at the pictures to get a quick overview.
“中间”是指“质心”,即重心(如果它是厚度和密度恒定的 3D 物体)?
如果是这样,则选择两个点,并找到它们之间的中点。 然后取这个中点和第三个点,找到它们之间 1/3 的点(更接近中点)。 那是你的质心。 我不是在给你算算。
By "middle" do you mean "centroid", a.k.a. the center of gravity if it were a 3D object of constant thickness and density?
If so, then pick two points, and find the midpoint between them. Then take this midpoint and the third point, and find the point 1/3 of the way between them (closer to the midpoint). That's your centroid. I'm not doing the math for you.