找到圆点 [英] Find points on circle

查看:158
本文介绍了找到圆点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的编码在C ++中,有半圈,从AA某一点(例如:(0,-310)),并在某一个点整理(0310)。我们有半径,我们有方程 X ^ 2 + Y ^ 2 = R ^ 2 。现在,我们正试图计算在这个圈子里的一些行(比如10+)点。

We are coding in C++, have half a circle, starting a a certain point (e.g. (0,-310)) and finishing at a certain point (0,310). We have the radius, and we have the equation X^2 + Y^2 = r^2. Now we are trying to calculate some (say 10+) points on the line of this circle.

因此​​,我们试图建立一个增量,将计算这些点之间的Y / X值,使用上述所示的等式,以确保所有计算出的点上的圆的线

Hence, we are trying to create an increment that will calculate the Y/X values between these points, using the equation shown above to make sure that all the points calculated are on the line of the circle.

一旦我们有了这些点,我们正试图把他们分成几个复杂的公式来计算机器人手臂是绘制这种形状的角度。这不是真正的优先级,但我想我应该包括我们在这个问题总体目标。

Once we have these points, we are trying to put them into several complex equations to calculate angles of a robot arm that is to draw this shape. This is not really the priority, but I thought I should include our overall aim in the question.

如何创建一个增量来计算我们两个开始点之间的半圈的行中的所有坐标?
然后把这些值代入方程中的code以上来计算所述机器人臂的角度。寻找一种方式来做到这一点而无需分别计算每一个点,即创建一个增量将做到这一点一气呵成。

How to create an increment to calculate all the coordinates on line of the half circle between our two start points?
Then put these values into the equations in the code above to calculate the angles of the robot arm. looking for a way to do this without calculating each point individually, i.e. create an increment that will do it in one go.

是什么样的,我们的目标为,计算出点以粗体显示。

This is kind of what we are aiming for, to calculate the points in bold.

推荐答案

确实需要点均匀分布?如果没有,那么你可以只直接使用您的公式:

Do the points need to be evenly spaced? If not, then you could just use your formula directly:

// assume half-circle centered at (0,0) and radius=310
double r = 310.0;
int n = 10;
for( int i=0; i<n; i++ )
{
   double x = i*r/n;
   double y = sqrt( r*r - x*x );
   // both (x,y) and (x,-y) are points on the half-circle
}

在此没有工作,所以也可以以x值的分布玩来近似连周围的圆间距

Once this is working, you could also play with the distribution of x values to approximate even spacing around the circle.

如果你的圈子是不是集中在(0,0)然后就抵消了计算(X,Y)通过实际的中心。

If your circle is not centered at (0,0) then just offset the computed (x,y) by the actual center.

这篇关于找到圆点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆