Advertisement
Guest User

Time To Impact

a guest
Jul 19th, 2017
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // cos true anomaly (cos(v))        cos(v) =  (((SMA(1-e^2))/r) - 1) / e
  3.  
  4.     local   geoimpact       IS  ADDONS:TR:IMPACTPOS.
  5.     local   SMAA            IS  SHIP:ORBIT:SEMIMAJORAXIS.
  6.     local   SMAB            IS  (SQRT((PERIAPSIS + SHIP:BODY:RADIUS) * (APOAPSIS + SHIP:BODY:RADIUS))).
  7.     local   Ecce            IS  SQRT(1 - ((SMAB^2)/(SMAA^2))).
  8.     local   radiusimp       IS  (SHIP:BODY:RADIUS + geoimpact:TERRAINHEIGHT).
  9.     local   radiuscur       IS  (SHIP:ALTITUDE + SHIP:BODY:RADIUS).
  10.     local   cosvimp         IS  ((((SMAA * (1 - ecce^2)) / radiusimp) - 1) / ecce).
  11.     local   cosvcur         IS  ((((SMAA * (1 - ecce^2)) / radiuscur) - 1) / ecce).
  12.    
  13. // eccentric anomaly (E)            E = ArcCos [ (e + cos(v)) / (1 + e * cos(v)) ]
  14.  
  15.     local   EcceAnomImp     IS  ARCCOS((ecce + cosvimp) / (1 + ecce * cosvimp)).
  16.     local   EcceAnomCur     IS  ARCCOS((ecce + cosvcur) / (1 + ecce * cosvcur)).
  17.        
  18. // Mean anomaly (M)                 M = E - e * sin(E)
  19.  
  20.     LOCAL MeanAnomImp           IS ecceAnomImp - (ecce * SIN(ecceAnomImp)).
  21.     LOCAL MeanAnomCur           IS ecceAnomCur - (ecce * SIN(ecceAnomCur)).
  22.    
  23. // Mean notion anomaly (n)          n = 360 / P
  24.  
  25.     local   gravmu          IS  (SHIP:BODY:MASS * CONSTANT:G).
  26.     local   orbperiod       IS  (2 * constant:pi * SQRT((SMAA^3)/(GravMu))).
  27.     local   meanmotion      IS  (360 / orbperiod).     
  28.    
  29. // Time calc
  30.  
  31.     local   deltatime       IS  (MeanAnomCur - MeanAnomImp)/Meanmotion.
  32.    
  33.     print   "time to impact: " + ROUND(deltatime) + " seconds.".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement