# [SDL] Orbiting sprites.

Chris Heller heller at teragram.com
Wed Sep 24 14:41:01 PDT 2003

```Ah, now things are starting to become clear.
That looks familiar.

I'll test it out this evening (no game coding at work :-( ) and let you
know how it goes.

Thanks!
Chris

-----Original Message-----
From: Neil Brown [mailto:neil at twistedsquare.com]
Sent: Wednesday, September 24, 2003 5:36 PM
To: sdl at libsdl.org
Subject: RE: [SDL] Orbiting sprites.

>
>So I guess my question is a simple as what do I need to do to calculate

>movement along a curved path?
>
>Something is telling me this all comes down to basic trigonometry,
>right?

I came in late on this one but assuming you're in 2d here (not 3d):

You have two radiuses for most ellipses, rx and ry (horizontal and
vertical).

Each iteration you want to move A radians around the ellipse, from your

So each iteration your movement must be:

X direction: cos(A+P)*rx - cos(P)*rx
Y direction: sin(A+P)*ry - sin(P)*ry

I think thats the sort of thing you are looking for right?  Tell me if
Ive misunderstood (or indeed if the above is wrong!)

HTH,

Neil.

_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

```