Libraries‎ > ‎orbits‎ > ‎

Process body element

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:

Begin description:

sets the elements of a body to result in a more elliptical orbit.

End description

Process Keplerian elements

Begin NetLogo code:

set my-mass                      my-earth-mass * 5.97219e24set size                         (6371 * my-earth-radius) / distance-scale ; convert to kilometres and then scalelet semi-major-axis              my-semi-major-in-au * 149597871; kmlet longitude                    semi-major-axis mod 360 ; longitude of the ascending body not known so arbitrary valuelet argument                     90 ; of periapsis since unknownlet mean-anomaly                 my-mass mod 360 ; need arbitrary value since most bodies should have different degrees set my-number-from-the-sun       position last my-name ["a" "b" "c" "d" "e" "f" "g" "h" "i"]set color                        5 + my-number-from-the-sun * 10set my-length-of-year-in-seconds my-orbital-period-in-days * 24 * 60 * 60 ; enter in dayslet state-vector convert-orbital-elements-to-state-vectors                     my-eccentricity (semi-major-axis * 1000) my-inclination-in-degrees longitude argument mean-anomaly let x item 0 state-vector / (distance-scale * 1000) let y item 1 state-vector / (distance-scale * 1000)let z item 2 state-vector / ( distance-scale * 1000 )if x != 0 or y != 0       [ set my-initial-heading atan x y ]  ; converting from m/s to km/sset my-initial-x-velocity item 3 state-vector / 1000set my-initial-y-velocity item 4 state-vector / 1000set my-initial-z-velocity item 5 state-vector / 1000   if not the-world-is-3-d?[   ifelse abs x < abs y and abs x < abs z [       set x z       set my-initial-x-velocity my-initial-z-velocity][   if abs y < abs x and abs y < abs z [           set y z           set my-initial-y-velocity my-initial-z-velocity ]]   setxy x y]if the-world-is-3-d?  [setxyz x y z ; distance from center   facexyz my-initial-x-velocity my-initial-y-velocity my-initial-z-velocity    set my-initial-velocity-pitch pitch ] let initial-speed  ( sqrt ( my-initial-x-velocity ^ 2 + my-initial-y-velocity ^ 2 + my-initial-z-velocity ^ 2 )                            / distance-scale) * time-scale  if initial-speed > the-maximum-speed [set the-maximum-speed initial-speed]let f ( my-eccentricity * semi-major-axis )set my-minimum-distance-to-com semi-major-axis - fset my-maximum-distance-to-com semi-major-axis + f

End NetLogo code

Authored by Ethan Edwards and Ken Kahn. Based on a micro-behaviour by Maria Marinari and Ken Kahn

BehaviourComposer: ignore everything after this.