Thread: Elliptical trajectory / motion in as 2.0?

1. 9
posts
Registered User

Elliptical trajectory / motion in as 2.0?

Hey guys, first of all, sorry if this was asked before, i did use the search option first (glanced a bit) and didn't find something related quick so decided to ask:

Does anyone know the correct way for creating an elliptical motion in flash 8? I googled for ellipse equations and stumbled upon these:

http://en.wikipedia.org/wiki/Ellipse

Lower on the page there's also some code (javascript) which generates points that can then be connected to form an ellipse. tried to replicate that in flash, but haven't succeeded. Also, i was wondering if there was another way i could generate an ellipse, which looks more like this http://www.rsc.org/ej/JM/2000/b002092n/b002092n-f4.gif, in the sense that it's "tilted".

I am trying to replicate a sort of solar system, but with elliptical trajectories, and would have liked to have the sun in an upper corner and the planets rotating around it in a sort of "tilted" ellipse.

I also tried to modify the Circular Movement tut also http://www.kirupa.com/developer/mx/circular.htm.

2. 1,532
posts
I make half sense
parabola is another term

carousel is an example that would work, you could stick it in a MC then tilt the mc (check my sig or gotoandlearn.com for a carousel)

also you could just draw a circle squish it to an elipse, turn it, then make MC's follow the path.

3. 42
posts
Registered User
i wrote this recently it might be helpful if you want to make it dynamic. r1 is the width of the elipse, r2 is the height, tilt is the rotation, and speed is the number of degrees per frame that it moves at...

Code:
```onClipEvent(enterFrame) {
offset += speed;
offset %= 360;
_x = x_center + Math.cos(offset * Math.PI / 180) * r1 * Math.cos(tilt * Math.PI / 180) + Math.sin(offset * Math.PI / 180) * r2 * Math.sin(tilt * Math.PI / 180);
_y = y_center - Math.cos(offset * Math.PI / 180) * r1 * Math.sin(tilt * Math.PI / 180) + Math.sin(offset * Math.PI / 180) * r2 * Math.cos(tilt * Math.PI / 180);
}```
hope it's useful.

4. 9
posts
Registered User
thanks, it worked!

i was using a wrong formula, this worked perfectly.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•