Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to move one object (dot) in a circular path. How should I change the X and Y coordinates to accomplish this?

share|improve this question
1  
I'm betting you could find the answer to that question anywhere. This may help, for instance gamedev.stackexchange.com/questions/7365/… –  Kensai Mar 11 '11 at 7:20
    
ya thank you dude.. i got it.. +1 –  Ganapathy Mar 11 '11 at 7:29
add comment

2 Answers

up vote 13 down vote accepted

You can make it by using simple math.

X := originX + sin(angle)*Size;
Y := originY + cos(angle)*Size;

Origin is the center of your circle. Size is the radius of that circle. Thats it.

share|improve this answer
    
thanks dude this is the exact thing i want... +1 –  Ganapathy Mar 11 '11 at 7:37
add comment

There's another trick, where you use the sin(x+a) and cos(x+a) formulas, and that allows you to compute sin(a) and cos(a) -- a being the angle by which you want to move from your current position -- only once and do simply multiplication and additions at each step.

sin(x+a) = sin(x)*cos(a) + cos(x)*sin(a), iirc.

Of course, that assumes constant angular velocity.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.