Find a point on a circle circumference based on degrees

ⅰ亾dé卋堺 提交于 2019-12-25 04:59:26

问题


Let's say that you have a stick figure. Let's say the stick figure has an elbow and a hand. What if the stick figure wants to spin his hand in a windmill without moving his elbow? If the elbow serves as the center of a circle, and the hand must always be on the circle's circumference, and I know the exact location of the elbow and hand, how do I move the hand around the circle's circumference, while preserving the radius (the length of the arm between the elbow and hand because it really shouldn't shrink or grow)?

I need to move the coordinate of the hand along the circumference of a circle, where the center of the circle is the elbow. This is in 2D.

I have the coordinates of both points. I can calculate the radius which is the length of the line between the points. Knowing the circle's center and radius, how do I rotate the hand along the circle circumference? I want it to maintain the radius, but change positions on the circumference. Basically, it must act like it's hinged.

P.S: I had a picture, but Stack Overflow said I was too new... Blame Stack Overflow.


回答1:


Basic trigonometry says:

x = r * cos(a);
y = r * sin(a);

This does not take into account the rotation of the hand, just shows the point on the circle where the wrist will be. Is that what you are after?

EDIT: Sorry, that assumes the elbow is at (0, 0) and x +ve is right and y +ve is up.

Given the elbow is at (ex, ey) then wrist is at:

wx = ex + r * cos(a);
wy = ey + r * sin(a);

If, as happens in browsers, y is +ve down, then subtract instead of add.



来源:https://stackoverflow.com/questions/11335742/find-a-point-on-a-circle-circumference-based-on-degrees

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!