2D三角形发现中心

编程入门 行业动态 更新时间:2024-10-09 20:27:20
本文介绍了2D三角形发现中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

(是的,不幸的是,这是一门功课的问题)

(Yes, unfortunately, this is a homework question)

我已经给出用于与x和y坐标,旋转可变,所以在2D三角一个结构。从这些x和y坐标创建点,我应该周围画点的三角形,并适当利用旋转可变旋转。

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.

我熟悉OpenGL绘图三角形与GL_TRIANGLES。我的问题是某种提取一个三角形的中间和绘图它周围的顶点。

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.

我希望我已经正确的措辞这一点,因为我有点糊涂了。

I hope I've worded this properly, as I'm a little confused.

感谢。

编辑:是的,我所寻找的是质心

edit: Yes, what I am looking for is the centroid.

推荐答案

有不同的三角形的中心类型。 三角形的中心。查找三角形的中心快速的方法是平均所有点的坐标。例如:

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:

GLfloat centerX = (tri[0].x + tri[1].x + tri[2].x) / 3; GLfloat centerY = (tri[0].y + tri[1].y + tri[2].y) / 3;

当你找到中心,你将需要旋转你对中心三角形。要做到这一点,翻译,使中心现在是(0,0)。执行你的循环。现在,扭转先前进行的翻译。

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.

更多推荐

2D三角形发现中心

本文发布于:2023-11-29 10:56:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646195.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:角形   发现   中心

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!