I want to move one object (dot) in a circular path. How should I change the X and Y coordinates to accomplish this?
Answer
You can do that using simple math:
X := originX + cos(angle)*radius;
Y := originY + sin(angle)*radius;
(originX, originY) is the center of your circle. radius is its radius. That's it.
This works because the sine and cosine are mathematically related to the unit circle.
Image credit: LucasVB (Own work) [Public domain], via Wikimedia Commons. (Scaled down to 70%.)
No comments:
Post a Comment