Results 1 to 4 of 4
-
April 8th, 2008, 07:12 AM #19Registered User
postsElliptical 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.
Sorry if the question is dumb or already answered in a previous post. Thanks in advance!
-
April 8th, 2008, 07:29 AM #21,532I make half sense
posts
-
April 8th, 2008, 06:42 PM #342Registered User
postsi 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...
hope it's useful.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); }
-
April 9th, 2008, 03:38 AM #49Registered User
poststhanks, it worked!
i was using a wrong formula
, this worked perfectly.

Reply With Quote

Bookmarks