BehaviourComposer: ignore everything before this. Begin micro-behaviour: Begin description: Converts orbital elements of a body given at www.exoplanets.org to state vectors which we use in this model. End description Orbital converter Begin NetLogo code: to-report convert-orbital-elements-to-state-vectors [ ecc a i upper-omega lower-omega m0 ] set m0 m0 * pi / 180 let Mass [ my-mass ] of the-sun + my-mass let eca m0 + ecc / 2 let diff 10000 let eps 0.000001 let e1 0 let eca-degrees 0 while [ diff > eps ] [ set eca-degrees eca * 180 / pi set e1 eca - ( eca - ecc * sin ( eca-degrees ) - m0 ) / ( 1 - ecc * cos ( eca-degrees ) ) set diff abs ( e1 - eca ) set eca e1 ] let ceca cos ( eca-degrees ) let seca sin ( eca-degrees ) set e1 a * sqrt ( abs ( 1 - ecc * ecc ) ) let xw a * ( ceca - ecc ) let yw e1 * seca let edot sqrt ( ( g-in-standard-units * Mass ) / a ) / ( a * ( 1 - ecc * ceca ) ) let xdw -1 * a * edot * seca let ydw (a * sqrt ( abs ( 1 - ecc * ecc ))) * edot * ceca let Cw cos ( upper-omega ) let Sw sin ( upper-omega ) let co cos ( lower-omega ) let so sin ( lower-omega ) let ci cos ( i ) let si sin ( i ) let swci Sw * ci let cwci Cw * ci let pX Cw * co - so * swci let pY Cw * so + co * swci let pZ Sw * si let qx -1 * Sw * co - so * cwci let qy -1 * Sw * so + co * cwci let qz Cw * si let x xw * pX + yw * qx let y xw * pY + yw * qy let z xw * pZ + yw * qz let xd xdw * pX + ydw * qx let yd xdw * pY + ydw * qy let zd xdw * pZ + ydw * qz report ( list x y z xd yd zd )end End NetLogo code Implements the conversion used in http://orbitsimulator.com/formulas/OrbitalElements.htmlInformation about orbital elements and there uses can be found at http://en.wikipedia.org/wiki/Orbital_elements Authored by Maria Marinari and Ken Kahn. BehaviourComposer: ignore everything after this. |