计算了一圈的点的位置位置

2023-09-10 22:47:57 作者:陌上花开丶谁许涐一世流年

我有一个有点头脑的空白这一时刻。 我有一个问题,我需要计算的点围绕中心点的位置(假设他们都距离市中心和彼此间距相等)。 点的数量是可变的,以便它的DrawCirclePoints(中间体X) 我敢肯定有一个简单的解决方案,但对我的生活,我不能看到它:)

I'm having a bit of a mind blank on this at the moment. I've got a problem where I need to calculate the position of points around a central point (assuming they're all equidistant from the center and from each other). The number of points is variable so it's "DrawCirclePoints(int x)" I'm sure there's a simple solution, but for the life of me, I just can't see it :)

推荐答案

在θ角上的中心是(X0,Y0),半径r为(X0 +​​ R COS THETA,Y0 + R罪圆一个点THETA)。现在选择θ值平均介于0和二皮隔开的。

A point at angle theta on the circle whose centre is (x0,y0) and whose radius is r is (x0 + r cos theta, y0 + r sin theta). Now choose theta values evenly spaced between 0 and 2pi.