I'm trying to create a planet motion simulator like the one on http://www.nd.edu/~hahn/orbital/. I even got the script from the same place. But somehow, the motion of my planets is not proper. It works right on the demo that they have on their site. But since a lot of values have been hard coded, it's difficult to figure out whats a variable and what remains constant. I've put my script in too, in case someone can figure it out. Any help will do... property mySprite property myEllipseArea property pSemiMajorAxis property myRepSemiMajorAxis property pRevolutionDays property pEpsilon property pCenterH property pCenterV global gEarthDays on beginSprite me mInit me end beginSprite me on enterFrame me mySprite.loc = mRevolve(me) end enterFrame me on mInit me mySprite = sprite(me.spriteNum) myEllipseArea = power(pSemiMajorAxis, 1.5) * pRevolutionDays myRepSemiMajorAxis = pSemiMajorAxis * 500 end mInit me on mRevolve me xPos = 2*pi*gEarthDays / myEllipseArea YPos = XPos repeat while abs(YPos - (XPos + pEpsilon * sin(YPos))) >= 0.00001 YPos = XPos + pEpsilon * sin(YPos) end repeat vRadius = (myRepSemiMajorAxis * (1 - pEpsilon * cos(YPos))) vAlpha = 2 * atan(sqrt((1 + pEpsilon) / (1 - pEpsilon)) * tan(YPos / 2)) if vAlpha <= pi / 2 AND vAlpha > 0 then dY = - sin(vAlpha) * vRadius dX = sqrt((vRadius * vRadius) - (dY * dY)) else if vAlpha > pi / 2 AND vAlpha <= pi then dY = - sin(pi - vAlpha) * vRadius dX = - sqrt((vRadius * vRadius)-(dY * dY)) else if - vAlpha > pi/2 AND - vAlpha <= pi then dY = sin(pi + vAlpha) * vRadius dX = - sqrt((vRadius * vRadius)-(dY * dY)) else if - vAlpha <= pi / 2 AND - vAlpha > 0 then dY = sin(-vAlpha) * vRadius dX = sqrt((vRadius * vRadius) - (dY * dY)) end if end if end if end if dX = dX + pCenterH dY = dY + pCenterV return point(dX, dY) end mRevolve me on getPropertyDescriptionList Desc = [:] addProp Desc, #pSemiMajorAxis, [#default: 1, #format: #float, #comment: "Length of the semi major axis of this planet:"] addProp Desc, #pRevolutionDays, [#default: 365, #format: #float, #comment: "Number of earth days taken for a complete revolution:"] addProp Desc, #pEpsilon, [#default: 0.4, #format: #float, #comment: "Epsilon:"] addProp Desc, #pCenterH, [#default: 320, #format: #integer, #comment: "Horizontal center of revolution:"] addProp Desc, #pCenterV, [#default: 240, #format: #integer, #comment: "Vertical center of revolution:"] return Desc end getPropertyDescriptionList Regards, Pranav _____________________________________________________ Chat with your friends as soon as they come online. Get Rediff Bol at http://bol.rediff.com [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]) Lingo-L is for learning and helping with programming Lingo. Thanks!]
