如何计算圆的圆周上的点的(x或y)坐标?

问题描述:

pxpy是圆圆周上的点的x和y坐标.

px and py are the x and y coordinates of a point on a circle's circumference.

给出:

the center of the circle as: cx, cy
the radius of the circle as: r
px

如何计算py的值?谢谢!

给出px,py最多有两个可能的值.

Given px there are at most two possible values for py.

看看勾股定理:(px-cx)^ 2 +(py-cy)^ 2 = r ^ 2.

Look at the pythagorean theorem: (px-cx)^2+(py-cy)^2=r^2.

让d = r ^ 2-(px-cx)^ 2

Let d=r^2-(px-cx)^2

如果d> 0,那么您有两个解决方案.得出py = sqrt(d)+ cy,其中平方根为正或负.

If d>0 then you have two solutions. This gives py=sqrt(d)+cy, where the square root is positive or negative.

如果d = 0,则您有一个解py = cy,即圆的左侧或右侧,具体取决于px

If d=0 then you have one solution py=cy, the left or right of the circle, depending on px

如果d

If d<0 you have no real points.