Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cos true anomaly (cos(v)) cos(v) = (((SMA(1-e^2))/r) - 1) / e
- local geoimpact IS ADDONS:TR:IMPACTPOS.
- local SMAA IS SHIP:ORBIT:SEMIMAJORAXIS.
- local SMAB IS (SQRT((PERIAPSIS + SHIP:BODY:RADIUS) * (APOAPSIS + SHIP:BODY:RADIUS))).
- local Ecce IS SQRT(1 - ((SMAB^2)/(SMAA^2))).
- local radiusimp IS (SHIP:BODY:RADIUS + geoimpact:TERRAINHEIGHT).
- local radiuscur IS (SHIP:ALTITUDE + SHIP:BODY:RADIUS).
- local cosvimp IS ((((SMAA * (1 - ecce^2)) / radiusimp) - 1) / ecce).
- local cosvcur IS ((((SMAA * (1 - ecce^2)) / radiuscur) - 1) / ecce).
- // eccentric anomaly (E) E = ArcCos [ (e + cos(v)) / (1 + e * cos(v)) ]
- local EcceAnomImp IS ARCCOS((ecce + cosvimp) / (1 + ecce * cosvimp)).
- local EcceAnomCur IS ARCCOS((ecce + cosvcur) / (1 + ecce * cosvcur)).
- // Mean anomaly (M) M = E - e * sin(E)
- LOCAL MeanAnomImp IS ecceAnomImp - (ecce * SIN(ecceAnomImp)).
- LOCAL MeanAnomCur IS ecceAnomCur - (ecce * SIN(ecceAnomCur)).
- // Mean notion anomaly (n) n = 360 / P
- local gravmu IS (SHIP:BODY:MASS * CONSTANT:G).
- local orbperiod IS (2 * constant:pi * SQRT((SMAA^3)/(GravMu))).
- local meanmotion IS (360 / orbperiod).
- // Time calc
- local deltatime IS (MeanAnomCur - MeanAnomImp)/Meanmotion.
- print "time to impact: " + ROUND(deltatime) + " seconds.".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement