开发者

How to calculate the (x or y) coordinate of point on a circumference of a circle?

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

Given:

the开发者_Python百科 center of the circle as: cx, cy
the radius of the circle as: r
px

How to calculate the value of py? Thanks!


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

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

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

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

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

If d<0 you have no real points.


Although this is not programming... you know this equation right?

(x - h)^2 + (y - k)^2 = r^2

You have h and k from cx and cy

You have r

you have x from px

then is easy to solve it!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜