moving an object around another object in a circle

the code is in C# and im using XNA
but im just looking for help with the math i need in order to move an object(the moon) around another object (the earth) in a circle.


Circles are really easy, you just need to use sine and cosine (which you don't have to understand, but it helps if you do).

Generally, if (cx, cy) is the centerpoint (e.g. the object to revolve around), and t is time (e.g. in frames or ticks), and r is the radius (e.g. in pixels), you can calculate the (x, y) coordinates like this:

x = cx + r*cos(t)
y = cy + r*sin(t)

You can adjust it in places to make it faster, slower, more like an oval, etc.
Maybe if you posted code we could help more.
@Lumpkin, I don't think posting C# on a C++ forum is a good suggestion. He already stated he only needs math help anyway...
thank you very much, that was exactly what i needed!
Topic archived. No new replies allowed.