moving an object around another object in a circle

Aug 29, 2013 at 12:02am
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.


Aug 29, 2013 at 12:37am
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.
Aug 29, 2013 at 1:06am
closed account (N36fSL3A)
Maybe if you posted code we could help more.
Aug 29, 2013 at 1:31am
@Lumpkin, I don't think posting C# on a C++ forum is a good suggestion. He already stated he only needs math help anyway...
Aug 29, 2013 at 4:22am
thank you very much, that was exactly what i needed!
Topic archived. No new replies allowed.