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.

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.

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.

@Lumpkin, I don't think posting C# on a C++ forum is a good suggestion. He already stated he only needs math help anyway...

Topic archived. No new replies allowed.