Advertisement
wirawafiy1

Orbital landing

Oct 27th, 2023
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.90 KB | None | 0 0
  1. CLEARSCREEN.
  2. set Pousser to 0.
  3. set directionCommande to -90.
  4. set pitchCommande to 0.
  5. LOCK THROTTLE TO Pousser.
  6. LOCK STEERING TO HEADING(directionCommande,pitchCommande).
  7.  
  8. set t0 to TIME:SECONDS.
  9. set t to 0.
  10. set dt to 0.05.
  11. set BetaF to 0.
  12. set Vdt to 0.
  13. set Hfusée to ALT:RADAR.
  14. set Conste to 2.71828182846.
  15. set Dfreinage2 to 10000.
  16.  
  17. stage.
  18.  
  19. set Latcible to -0.097215540.
  20. set longcible to -74.557701108.
  21. // set Latcible to 6.
  22. // set longcible to -62.
  23.  
  24.  
  25. set Mission to 1.
  26.  
  27. wait 20.
  28.  
  29. set Hlim to 50000.
  30. set AngleAtt to 30.
  31. set ListLatCurr to list().
  32. set ListLongCurr to list().
  33.  
  34. set ETAPE to "attente".
  35.  
  36. until Mission = 0 {
  37.  
  38. set dt to abs(t-(TIME:SECONDS-t0)).
  39. set t to TIME:SECONDS-t0.
  40.  
  41. // set CoordAtt to ZoneAtt.
  42.  
  43. // set LatAtt to CoordAtt[0].
  44. // set LongAtt to CoordAtt[1].
  45.  
  46. if ETAPE = "attente" {
  47.  
  48. set DdegP to ((Latcible-Ship:Latitude)^2+(longcible-SHIP:Longitude)^2)^0.5.
  49. set DminP to arccos(BODY:RADIUS/(BODY:RADIUS+SHIP:ALTITUDE))*1.6.
  50.  
  51. if DdegP < DminP {
  52.  
  53. CLEARSCREEN.
  54. print"calcul allumage de de-orbite".
  55. set Coord1Burn to CoordPetiteDistance(Latcible,Longcible,25000,AnglePetiteCoord(Ship:Latitude,ship:longitude,Latcible,longcible)).
  56.  
  57. set Lat1Burn to Coord1Burn[0].
  58.  
  59. set Long1Burn to Coord1Burn[1].
  60. set BurnAtt to RechercheDeorbitBurn(Lat1Burn,Long1Burn,70,10000,5).
  61.  
  62. set VbC to BurnAtt[0].
  63. set AngleBurn to BurnAtt[1].
  64. set Deltadistance to BurnAtt[2].
  65.  
  66. set T3 to TIME:SECONDS-t0.
  67.  
  68. set ImpSpe to ISPCurrent.
  69. set ShipThrust to SHIP:MAXTHRUST*1000.
  70. set Tb to DeltaTburn(ShipThrust,ImpSpe,VbC).
  71.  
  72. set directionCommande to AngleBurn.
  73. set pitchCommande to 0.
  74.  
  75. CLEARSCREEN.
  76. print "ETAPE: " + ETAPE at (0,0).
  77. print "VbC: " + round(VbC,2) at (0,2).
  78. print "AngleBurn: " + round(AngleBurn,2) at (0,3).
  79. print "Deltadistance: " + round(Deltadistance,2) at (0,4).
  80.  
  81. set ETAPE to "Allumage1".
  82.  
  83. } ELSE {
  84.  
  85. CLEARSCREEN.
  86. print "ETAPE: " + ETAPE at (0,0).
  87. print "t: " + round(t,2) at (0,2).
  88. print "Delta angle vaisseau/cible: " + round(DdegP,2) at (0,3).
  89. print "Delta angle minimum " + round(DminP,2) at (0,4).
  90.  
  91. }
  92.  
  93. }
  94.  
  95. if ETAPE = "Allumage1" {
  96.  
  97. CLEARSCREEN.
  98. print "ETAPE: " + ETAPE at (0,0).
  99. //print "t depuis etape Allumage1: " + round(T3,2) at (0,2).
  100. //print "t: " + round(t,2) at (0,1).
  101.  
  102.  
  103. if t > T3+5 and t < T3+5+Tb {
  104. print "temps d'allumage calcule :" + round(Tb,1) at (0,2).
  105. print "extinction dans :" + round(abs(t-(T3+5+Tb)),1) at (0,3).
  106. print "deltaV : " + round(VbC,2) at (0,4).
  107. print "azimute : " + round(AngleBurn,2) at (0,5).
  108. print "distance à la cible après Allumage1: " + round(Deltadistance,2) at (0,6).
  109. set Pousser to 1.
  110.  
  111. } ELSE {
  112. print "temps d'allumage calcule :" + round(Tb,1) at (0,2).
  113. print "allumage dans :" + round(T3+5-t,1) at (0,3).
  114. print "deltaV : " + round(VbC,2) at (0,4).
  115. print "azimute : " + round(AngleBurn,2) at (0,5).
  116. print "distance à la cible après Allumage1: " + round(Deltadistance,2) at (0,6).
  117. set Pousser to 0.
  118.  
  119. }
  120.  
  121. if t > T3+5+Tb {
  122.  
  123. set ETAPE to "Attente2".
  124.  
  125. }
  126.  
  127.  
  128. }
  129.  
  130. if ETAPE = "Attente2" {
  131.  
  132. set Dist2Burn to PetiteDistanceCoord(SHIP:LATITUDE,SHIP:LONGITUDE,Latcible,Longcible).
  133.  
  134. if SHIP:ALTITUDE < 60000 {
  135.  
  136. CLEARSCREEN.
  137. print"calcul allumage de re-entre".
  138.  
  139. set DistPlus to Dist2Burn*0.035.
  140.  
  141. set Coord2Burn to CoordPetiteDistance(Latcible,Longcible,DistPlus,AnglePetiteCoord(Ship:Latitude,ship:longitude,Latcible,longcible)).
  142.  
  143. set Lat2Burn to Coord2Burn[0].
  144. set Long2Burn to Coord2Burn[1].
  145.  
  146. set BurnAtt to RechercheDeorbitBurn(Lat2Burn,Long2Burn,70,2000,5).
  147.  
  148. set VbC to BurnAtt[0].
  149. set AngleBurn to BurnAtt[1].
  150. set Deltadistance to BurnAtt[2].
  151.  
  152. set T3 to TIME:SECONDS-t0.
  153.  
  154. set ImpSpe to ISPCurrent.
  155. set ShipThrust to SHIP:MAXTHRUST*1000.
  156. set Tb to DeltaTburn(ShipThrust,ImpSpe,VbC).
  157.  
  158. set directionCommande to AngleBurn.
  159. set pitchCommande to 0.
  160.  
  161. set ETAPE to "Allumage2".
  162.  
  163. } ELSE {
  164.  
  165. CLEARSCREEN.
  166. print "ETAPE: " + ETAPE at (0,0).
  167. //print "Dist2Burn(km): " + round(Dist2Burn/1000,2) at (0,1).
  168. print "En attente de l'allumage de re-entre a 60Km d'altitude" at (0,2).
  169.  
  170. }
  171.  
  172. }
  173.  
  174. if ETAPE = "Allumage2" {
  175.  
  176. CLEARSCREEN.
  177. print "ETAPE: " + ETAPE at (0,0).
  178. //print "allumage de re-entré dans 5s ..." at (0,1).
  179.  
  180. if t > T3+5 and t < T3+5+Tb {
  181. print "temps d'allumage calcule :" + round(Tb,1) at (0,2).
  182. print "extinction dans :" + round(abs(t-(T3+5+Tb)),1) at (0,3).
  183. print "deltaV : " + round(VbC,2) at (0,4).
  184. print "azimute : " + round(AngleBurn,2) at (0,5).
  185. print "distance à la cible après Allumage2: " + round(Deltadistance,2) at (0,6).
  186. set Pousser to 1.
  187.  
  188. } ELSE {
  189. print "temps d'allumage calcule :" + round(Tb,1) at (0,2).
  190. print "allumage dans :" + round(T3+5-t,1) at (0,3).
  191. print "deltaV : " + round(VbC,2) at (0,4).
  192. print "azimute : " + round(AngleBurn,2) at (0,5).
  193. print "distance à la cible après Allumage2: " + round(Deltadistance,2) at (0,6).
  194. set Pousser to 0.
  195.  
  196. }
  197.  
  198. if t > T3+5+Tb {
  199.  
  200. set ETAPE to "NavigationAerodynamique".
  201.  
  202. }
  203.  
  204.  
  205. }
  206.  
  207. if ETAPE = "NavigationAerodynamique" {
  208.  
  209. set Distcible to PetiteDistanceCoord(SHIP:LATITUDE,SHIP:LONGITUDE,Latcible,Longcible).
  210.  
  211. if Distcible < 40000 or Distcible/3 < Dfreinage2*cos(VShipPitch)/2 {
  212.  
  213. set DistSup to Dfreinage2*cos(VShipPitch)/2.5. // initialemnt /3
  214. set KLong to 0.07.
  215. set Kcote to 0.06.
  216.  
  217. if Distcible < 6000 {
  218.  
  219. set DistSup to Dfreinage2*cos(VShipPitch)/3.25. // if pas implemente
  220. set KLong to 0.07.
  221. set Kcote to 0.06.
  222. }
  223.  
  224.  
  225. } ELSE {
  226.  
  227. set DistSup to Distcible/2. // initialemnt /4
  228. set KLong to 0.003.
  229. set Kcote to 0.08.
  230.  
  231. }
  232.  
  233.  
  234. set Coordcibleact to CoordPetiteDistance(Latcible,Longcible,DistSup,AnglePetiteCoord(Ship:Latitude,ship:longitude,Latcible,longcible)).
  235. set Latcibleact to Coordcibleact[0].
  236. set Longcibleact to Coordcibleact[1].
  237.  
  238. set CoordCurrAtt to ZoneAttBurn(0,0,70,0).
  239.  
  240. set LatCurrAtt to CoordCurrAtt[0].
  241. set LongCurrAtt to CoordCurrAtt[1].
  242.  
  243. set LagMoy to Moy(LatCurrAtt,ListLatCurr,3).
  244. set LongMoy to Moy(LongCurrAtt,ListLongCurr,3).
  245.  
  246. set LatCurrMoy to LagMoy[0].
  247. set ListLatCurr to LagMoy[1].
  248.  
  249. set LongCurrMoy to LongMoy[0].
  250. set ListLongCurr to LongMoy[1].
  251.  
  252. set ErreurTot to PetiteDistanceCoord(LatCurrMoy,LongCurrMoy,Latcibleact,Longcibleact).
  253. set DistanceCibleact to PetiteDistanceCoord(SHIP:LATITUDE,SHIP:LONGITUDE,Latcibleact,Longcibleact).
  254. set DistanceCurrAtt to PetiteDistanceCoord(SHIP:LATITUDE,SHIP:LONGITUDE,LatCurrMoy,LongCurrMoy).
  255.  
  256. set AlpC to AnglePetiteCoord(Latcibleact,Longcibleact,LatCurrMoy,LongCurrMoy).
  257. set BetaC2 to VShipYaw.
  258. set BetaC2 to AlpC-BetaC2.
  259.  
  260. set AlpC2 to AnglePetiteCoord180(Latcibleact,Longcibleact,LatCurrMoy,LongCurrMoy).
  261. set BetaC3 to VShipYaw180.
  262. set BetaC3 to AlpC-BetaC3.
  263.  
  264. if BetaC2 = BetaC3 {
  265. set BetaF to BetaC2.
  266. } ELSE {
  267. if BetaF = 0 {
  268. set BetaC1 to 180-arccos(((ErreurTot^2)+(DistanceCibleact^2)-(DistanceCurrAtt^2))/(2*ErreurTot*DistanceCibleact)).
  269. } ELSE {
  270. set BetaC1 to BetaF.
  271. }
  272.  
  273. if BetaC2 > BetaC1-5 and BetaC2 < BetaC1+5 {
  274. set BetaF to BetaC2.
  275. } ELSE {
  276. set BetaF to BetaC3.
  277. }
  278. }
  279.  
  280. set erreurCote to sin(betaF)*ErreurTot.
  281. set erreurLong to cos(BetaF)*ErreurTot.
  282.  
  283. set DeltaVangle to 0.
  284.  
  285. if Distcible < 130000 {
  286.  
  287. set DeltaVangle to 15.
  288. BRAKES OFF.
  289.  
  290. if erreurLong > 1000 and Distcible < 100000 and SHIP:VELOCITY:SURFACE:MAG > 550 {
  291.  
  292. BRAKES ON.
  293.  
  294. }
  295.  
  296. if VShipPitch < -80 {
  297.  
  298. BRAKES ON.
  299.  
  300. }
  301.  
  302. }
  303.  
  304. set PitchCorr to MaxEnc(erreurLong*Klong,DeltaVangle).
  305. set DirCorr to MaxEnc(erreurCote*Kcote,DeltaVangle).
  306.  
  307. set pitchCommande to -VShipPitch+PitchCorr.
  308. set directionCommande to -VShipYaw-DirCorr.
  309.  
  310. set Vexp to SHIP:VELOCITY:SURFACE:MAG.
  311. set Cexptot to (-2/((Vexp^2)*pair(SHIP:ALTITUDE)))*(SHIP:MASS*1000*AccSur+SHIP:MASS*1000*gr*sin(VShipPitch)).
  312.  
  313. if VShipPitch < -83 {
  314.  
  315. set ETAPE to "AttenteFinalBurn".
  316.  
  317. }
  318.  
  319. set ShipThrust to 1*SHIP:MAXTHRUST.
  320. set Vsur to SHIP:VELOCITY:SURFACE:MAG.
  321. set ImpSpe to ISPCurrent.
  322. // set DistanceMinFreinage to 1.5*((Vsur^2)/((0.9*ShipThrust/SHIP:MASS)-sin(VShipPitch)*gr)).
  323.  
  324. set DistanceReel to ALT:RADAR/sin(-VShipPitch).
  325. // set TburnDuration to SHIP:MASS*(1-(1/(Conste^((Vsur+(2*9.81*sin(-VShipPitch)*ALT:RADAR)^0.5)/(9.81*ImpSpe)))))/(ShipThrust/(9.81*ImpSpe)).
  326. // set Dfreinage to ((Vsur+((2*9.81*sin(-VShipPitch)*ALT:RADAR)^0.5))/2)*TburnDuration.
  327.  
  328. set Dfreinage2 to 0.5*((Vsur^2)/((0.8*ShipThrust/SHIP:MASS)+((0.333*pair(0)*3*Vsur^2)/(SHIP:MASS*1000))+sin(VShipPitch)*gr)).
  329.  
  330. if Dfreinage2/1.05 > DistanceReel and Distcible < 9000 { // init Dfreinage2 > DistanceReel and Distcible < 9000
  331.  
  332. set ETAPE to "AllumageFinal".
  333. set DdebBurn to Distcible.
  334. set VhoridebBurn to SHIP:GROUNDSPEED.
  335. set Kvihori to 1*VhoridebBurn/DdebBurn.
  336. set PitchMaxfuse to -VShipPitch.
  337.  
  338. }
  339.  
  340. CLEARSCREEN.
  341. print "ETAPE: " + ETAPE at (0,0).
  342. print "distance a la cible actuelle (km) : " + round(Distcible/1000,2) at (0,2).
  343. print "distance superieur (a la cible) vise: " + round(DistSup,2) at (0,3).
  344. print "distance (simule) de l'erreur a corriger (m) : " + round(ErreurTot,2) at (0,4).
  345. print "erreur transverse a corriger (m) : " + round(erreurCote,2) at (0,5).
  346. print "erreur longitudinale a corriger (m) : " + round(erreurLong,2) at (0,6).
  347. print "correction en tengage (degres): " + round(PitchCorr,2) at (0,7).
  348. print "correction en lacet (degres): " + round(DirCorr,2) at (0,8).
  349. print "evaluation du coef de friction à: " + round(Cexptot,2) at (0,9).
  350.  
  351. print "estimation distance au sol: " + round(DistanceReel,2) at (0,10).
  352. print "estimation de la distance de freinage final: " + round(Dfreinage2,2) at (0,11).
  353. print "allumage final lorsque 'distance sol = distance freinage' " at (0,13).
  354.  
  355. //print "AccSur: " + round(AccSur,5) at (0,7).
  356. //print "DistanceCurrAtt: " + round(DistanceCurrAtt,2) at (0,6).
  357. // print "TburnDuration: " + round(TburnDuration,2) at (0,12).
  358.  
  359. }
  360.  
  361. if ETAPE = "AttenteFinalBurn" {
  362.  
  363. set ShipThrust to 1*SHIP:MAXTHRUST.
  364. set Vsur to SHIP:VELOCITY:SURFACE:MAG.
  365. set ImpSpe to ISPCurrent.
  366.  
  367. set DistanceReel to ALT:RADAR/sin(-VShipPitch).
  368. // set TburnDuration to SHIP:MASS*(1-(1/(Conste^((Vsur+(2*9.81*sin(-VShipPitch)*DistanceReel)^0.5)/(9.81*ImpSpe)))))/(ShipThrust/(9.81*ImpSpe)).
  369. // set Dfreinage to ((Vsur+((2*9.81*sin(-VShipPitch)*DistanceReel)^0.5))/2)*TburnDuration.
  370.  
  371. set CoordCurrAtt to ZoneAttBurn(0,0,70,0).
  372.  
  373. set LatCurrAtt to CoordCurrAtt[0].
  374. set LongCurrAtt to CoordCurrAtt[1].
  375.  
  376. set ErreurTot to PetiteDistanceCoord(LatCurrAtt,LongCurrAtt,Latcible,Longcible).
  377.  
  378. if ErreurTot < 250 {
  379.  
  380. BRAKES ON.
  381.  
  382. } ELSE {
  383.  
  384. BRAKES OFF.
  385.  
  386. }
  387.  
  388. // if ErreurTot > 400 and BurnCoor = 0 {
  389.  
  390. // set BurnAtt to RechercheDeorbitBurn(Latcible,Longcible,70,300,1).
  391.  
  392. // set VbC to BurnAtt[0].
  393. // set AngleBurn to BurnAtt[1].
  394. // set Deltadistance to BurnAtt[2].
  395.  
  396. // set PitchDeCorrection to -VShippitch.
  397.  
  398. // set ImpSpe to ISPCurrent*cos(PitchDeCorrection).
  399. // set ShipThrust to SHIP:MAXTHRUST*1000*cos(PitchDeCorrection).
  400. // set Tb to DeltaTburn(ShipThrust,ImpSpe,VbC).
  401. // set T3 to TIME:SECONDS-t0.
  402.  
  403. // CLEARSCREEN.
  404. // print "VbC: " + round(VbC,2) at (0,1).
  405. // print "Tb: " + round(Tb,2) at (0,2).
  406. // print "AngleBurn: " + round(AngleBurn,2) at (0,3).
  407.  
  408. // until t > T3 + Tb or ErreurTot < 250 {
  409.  
  410. // set Pousser to 1.
  411. // set directionCommande to AngleBurn.
  412. // set PitchCommande to -PitchDeCorrection.
  413. // set t to TIME:SECONDS-t0.
  414.  
  415. // set CoordCurrAtt to ZoneAttBurn(0,0,70,0).
  416. // set LatCurrAtt to CoordCurrAtt[0].
  417. // set LongCurrAtt to CoordCurrAtt[1].
  418. // set ErreurTot to PetiteDistanceCoord(LatCurrAtt,LongCurrAtt,Latcible,Longcible).
  419.  
  420.  
  421. // }
  422.  
  423. // set Pousser to 0.
  424. // set BurnCoor to 1.
  425.  
  426. // }
  427.  
  428.  
  429.  
  430. set Kvihori to 0.2.
  431. set Kacchri to 1.
  432. set Kpenchhori to 1.5.
  433.  
  434. set AngleDeDeplacement to AnglePetiteCoord(LatCurrAtt,LongCurrAtt,Latcible,longcible).
  435. set VitesseHoriCible to PetiteDistanceCoord(LatCurrAtt,LongCurrAtt,Latcible,longcible)*Kvihori.
  436. set deltaAngle1 to (AngleDeDeplacement-VShipYaw).
  437.  
  438. set VitesseHoriCommande to (abs((SHIP:GROUNDSPEED^2)+(VitesseHoriCible^2)-2*VitesseHoriCible*SHIP:GROUNDSPEED*cos(abs(deltaAngle1))))^0.5.
  439. set AccelerationHoriCible to VitesseHoriCommande*Kacchri.
  440.  
  441. set ValeurDepenchement to VitesseHoriCommande*Kpenchhori.
  442.  
  443. set pitchCommande to MAX((90-ValeurDepenchement),70).
  444. set directionCommande to 180+ARCTAN2((VitesseHoriCible*sin(AngleDeDeplacement)-SHIP:GROUNDSPEED*sin(VShipYaw)),(VitesseHoriCible*cos(AngleDeDeplacement)-SHIP:GROUNDSPEED*cos(VShipYaw))).
  445.  
  446.  
  447. set Dfreinage2 to 0.5*((Vsur^2)/((0.8*ShipThrust/SHIP:MASS)+sin(VShipPitch)*gr)).
  448.  
  449. if Dfreinage2 > DistanceReel and Distcible < 9000 {
  450.  
  451. set ETAPE to "Final Burn".
  452.  
  453.  
  454. }
  455.  
  456. CLEARSCREEN.
  457. print "ETAPE: " + ETAPE at (0,0).
  458. // print "ErreurTot: " + round(ErreurTot,2) at (0,1).
  459. // print "DistanceReel: " + round(DistanceReel,2) at (0,2).
  460. // print "Dfreinage: " + round(Dfreinage,2) at (0,3).
  461. // print "DistanceReel: " + round(DistanceReel,5) at (0,4).
  462. // print "directionCommande: " + round(directionCommande,5) at (0,5).
  463.  
  464. // print "PitchCorr: " + round(PitchCorr,5) at (0,6).
  465. // print "AccSur: " + round(AccSur,5) at (0,7).
  466. // print "Cexptot: " + round(Cexptot,5) at (0,8).
  467.  
  468. }
  469.  
  470. if ETAPE = "AllumageFinal" {
  471.  
  472. GEAR ON.
  473. BRAKES ON.
  474. RCS ON.
  475.  
  476. set DistanceReel to ALT:RADAR/sin(-VShipPitch).
  477. set Dsol to ALT:RADAR/tan(-VShipPitch).
  478.  
  479. // set CoordCuratt to CoordPetiteDistance(Ship:Latitude,ship:longitude,Dsol,VShipYaw).
  480. // set LatCurrAtt to CoordCuratt[0].
  481. // set LongCurrAtt to CoordCuratt[1].
  482.  
  483. // set ErreurTot to PetiteDistanceCoord(LatCurrAtt,LongCurrAtt,Latcible,Longcible).
  484. // set DistanceCibleact to PetiteDistanceCoord(SHIP:LATITUDE,SHIP:LONGITUDE,Latcible,Longcible).
  485. // set DistanceCurrAtt to PetiteDistanceCoord(SHIP:LATITUDE,SHIP:LONGITUDE,LatCurrAtt,LongCurrAtt).
  486.  
  487. // set AlpC to AnglePetiteCoord(Latcible,Longcible,LatCurrAtt,LongCurrAtt).
  488. // set BetaC2 to VShipYaw.
  489. // set BetaC2 to AlpC-BetaC2.
  490.  
  491. // set AlpC2 to AnglePetiteCoord180(Latcible,Longcible,LatCurrAtt,LongCurrAtt).
  492. // set BetaC3 to VShipYaw180.
  493. // set BetaC3 to AlpC-BetaC3.
  494.  
  495. // if BetaC2 = BetaC3 {
  496. // set BetaF to BetaC2.
  497. // } ELSE {
  498. // if BetaF = 0 {
  499. // set BetaC1 to 180-arccos(((ErreurTot^2)+(DistanceCibleact^2)-(DistanceCurrAtt^2))/(2*ErreurTot*DistanceCibleact)).
  500. // } ELSE {
  501. // set BetaC1 to BetaF.
  502. // }
  503.  
  504. // if BetaC2 > BetaC1-5 and BetaC2 < BetaC1+5 {
  505. // set BetaF to BetaC2.
  506. // } ELSE {
  507. // set BetaF to BetaC3.
  508. // }
  509. // }
  510.  
  511. // set erreurCote to sin(betaF)*ErreurTot.
  512. // set erreurLong to cos(BetaF)*ErreurTot.
  513.  
  514.  
  515. set ShipThrust to SHIP:MAXTHRUST.
  516. set Vsur to SHIP:VELOCITY:SURFACE:MAG.
  517. set ImpSpe to ISPCurrent.
  518.  
  519. // set TburnDuration to SHIP:MASS*(1-(1/(Conste^((Vsur+(2*9.81*sin(-VShipPitch)*ALT:RADAR)^0.5)/(9.81*ImpSpe)))))/(ShipThrust/(9.81*ImpSpe)).
  520. // set Dfreinage to ((Vsur+((2*9.81*sin(-VShipPitch)*ALT:RADAR)^0.5))/2)*TburnDuration.
  521.  
  522.  
  523. // set EltCal1 to SHIP:MASS*(1-(1/(Conste^((Vsur+(2*9.81*sin(-VShipPitch)*DistanceReel)^0.5)/(9.81*ImpSpe))))).
  524. // set Pousser to ((Vsur+(2*9.81*sin(-VShipPitch)*DistanceReel)^0.5)*EltCal1*9.81*ImpSpe)/(2*ShipThrust*DistanceReel).
  525.  
  526. set Pousser to (((Vsur^2)/(2*(DistanceReel-Hfusée)))-sin(VShipPitch)*9.81)*(SHIP:MASS/ShipThrust)/sin(ShipPitch).
  527.  
  528. // set pitchCommande to -VShipPitch.
  529. // set directionCommande to -VShipYaw.
  530.  
  531. // set ShipThrust to 1*SHIP:MAXTHRUST.
  532. // set Vsur to SHIP:VELOCITY:SURFACE:MAG.
  533. // set DistanceReel to ALT:RADAR/sin(-VShipPitch).
  534. // set Pousser to ((SHIP:MASS/(ShipThrust))*((1*(Vsur^2))/(2*DistanceReel)+sin(VShipPitch)*gr))/sin(ShipPitch).
  535.  
  536. set PitchMax to arcsin(min(Pousser,1)).
  537. set PitchMax to max(PitchMax,PitchMaxfuse).
  538.  
  539. // set Kvihori to 0.16.
  540. set Kacchri to 1.
  541.  
  542. set AngleDeDeplacement to AnglePetiteCoord(SHIP:LATITUDE,SHIP:LONGITUDE,Latcible,longcible).
  543. set VitesseHoriCible to min(PetiteDistanceCoord(SHIP:LATITUDE,SHIP:LONGITUDE,Latcible,longcible)*Kvihori,((ALT:RADAR-Hfusée)/10)^2).
  544. set deltaAngle1 to (AngleDeDeplacement-VShipYaw).
  545.  
  546. set VitesseHoriCommande to (abs((SHIP:GROUNDSPEED^2)+(VitesseHoriCible^2)-2*VitesseHoriCible*SHIP:GROUNDSPEED*cos(abs(deltaAngle1))))^0.5.
  547. set AccelerationHoriCible to VitesseHoriCommande*Kacchri.
  548.  
  549. set ValeurArcsin to Min((AccelerationHoriCible*SHIP:MASS/(ShipThrust*Pousser)),1).
  550. set ValeurArcsin to Max(ValeurArcsin,-1).
  551.  
  552. set pitchCommande to MAX((90-arcsin(ValeurArcsin)),PitchMax).
  553. set directionCommande to ARCTAN2((VitesseHoriCible*sin(AngleDeDeplacement)-SHIP:GROUNDSPEED*sin(VShipYaw)),(VitesseHoriCible*cos(AngleDeDeplacement)-SHIP:GROUNDSPEED*cos(VShipYaw))).
  554.  
  555. CLEARSCREEN.
  556. print "ETAPE: " + ETAPE at (0,0).
  557. print "Pousser moteur: " + round(Pousser,2) at (0,2).
  558. print "estimation distance au sol: " + round(DistanceReel,2) at (0,3).
  559. print "commande en azimute: " + round(directionCommande,2) at (0,4).
  560. print "commande en tangage : " + round(pitchCommande,2) at (0,5).
  561. print "vitesse horizontale cible: " + round(VitesseHoriCible,2) at (0,6).
  562. print "coef correction Kvihori: " + round(Kvihori,5) at (0,7).
  563. // print "AccSur: " + round(AccSur,5) at (0,7).
  564.  
  565. if SHIP:VERTICALSPEED > 0 and (ALT:RADAR-Hfusée) < 1 {
  566. set Pousser to 0.
  567. set ETAPE to "stabilisation".
  568.  
  569.  
  570. }
  571.  
  572. }
  573.  
  574. if ETAPE = "stabilisation"{
  575.  
  576. set pitchCommande to 90.
  577. CLEARSCREEN.
  578. print "fin de mission".
  579.  
  580. }
  581.  
  582. // print "Lat: " + round(SHIP:LATITUDE,2) at (0,1).
  583. // print "Long: " + round(SHIP:LONGITUDE,2) at (0,2).
  584.  
  585. // print "LatAtt: " + round(LatAtt,2) at (0,4).
  586. // print "LongAtt: " + round(LongAtt,2) at (0,5).
  587.  
  588. //print "Vterminal: " + round(Vterminal,2) at (0,11).
  589. // print "Lat: " + round(SHIP:LATITUDE,2) at (0,12).
  590.  
  591.  
  592. }
  593.  
  594.  
  595. function ZoneAtt {
  596.  
  597. set Pi to 3.14159265359.
  598. set Rc to 8.3144621.
  599.  
  600. set dt to 1.
  601. set t to 0.
  602.  
  603. set V to SHIP:VELOCITY:ORBIT:MAG.
  604.  
  605. set R to SHIP:ALTITUDE+BODY:RADIUS.
  606. set dR to SHIP:VERTICALSPEED.
  607. set PHI to SHIP:LONGITUDE*(2*Pi/360).
  608. set dPHI to (V*cos(VShipPitchO)*sin(VShipYawO))/R.
  609. set THETA to (90-SHIP:LATITUDE)*(2*Pi/360).
  610. set dTHETA to -V*cos(VShipPitchO)*cos(VShipYawO)/R.
  611.  
  612. set Masse to SHIP:MASS*1000.
  613.  
  614. // CLEARSCREEN.
  615. // print "dR: " + round(dR,2) at (0,1).
  616. // print "PHI: " + round(PHI,4) at (0,2).
  617. // print "dPHI: " + round(dPHI,6) at (0,3).
  618. // print "THETA: " + round(THETA,4) at (0,4).
  619. // print "dTHETA: " + round(dTHETA,6) at (0,5).
  620.  
  621. // wait 1.
  622.  
  623. // CLEARSCREEN.
  624.  
  625. set Config:IPU to 1500.
  626.  
  627. until R < BODY:RADIUS or t > 15*60 {
  628.  
  629. if R-Body:Radius < Body:ATM:HEIGHT {
  630.  
  631. set p to (((body:atm:ALTITUDEPRESSURE(R-body:radius)*Constant:AtmToKPa*1000)*(28.9644/1000))/(Rc*220)).
  632. set S to 1.
  633. set Cx to 1.
  634.  
  635. set Ftr to 0.5*p*S*Cx*(dR^2).
  636. set Ftt to 0.5*p*S*Cx*((R*dTHETA)^2).
  637. set Ftp to 0.5*p*S*Cx*((R*sin(THETA*(360/(2*Pi)))*dPHI)^2).
  638.  
  639. if dR > 0 {
  640. set Ftr to -Ftr.
  641. }
  642. if dTHETA > 0 {
  643. set Ftt to -Ftt.
  644. }
  645. if dPHI > 0 {
  646. set Ftp to -Ftp.
  647. }
  648.  
  649. } ELSE {
  650.  
  651. set Ftr to 0.
  652. set Ftt to 0.
  653. set Ftp to 0.
  654.  
  655. }
  656.  
  657. set dRdt to ((-BODY:MU/(R^2))+R*(dPHI^2)*(sin(THETA*(360/(2*Pi)))^2)+R*(dTHETA^2)+(Ftr/Masse))*dt+dR.
  658. set dTHETAdt to (1/R)*(R*(dPHI^2)*sin(THETA*(360/(2*Pi)))*cos(THETA*(360/(2*Pi)))-2*dR*dTHETA+(Ftt/Masse))*dt+dTHETA.
  659. set dPHIdt to (1/(R*sin(THETA*(360/(2*Pi)))))*(-2*dR*dPHI*sin(THETA*(360/(2*Pi)))-2*R*dTHETA*dPHI*cos(THETA*(360/(2*Pi)))+(Ftp/Masse))*dt+dPHI.
  660.  
  661. set R to dR*dt + R.
  662. set THETA to dTHETA*dt + THETA.
  663. set PHI to dPHI*dt + PHI.
  664.  
  665. set dR to dRdt.
  666. set dPHI to dPHIdt.
  667. set dTHETA to dTHETAdt.
  668.  
  669. set t to t + dt.
  670.  
  671. }
  672.  
  673. set Config:IPU to 150.
  674.  
  675. set Vter to ((dR^2)+((R*dTHETA)^2)+((R*sin(THETA*(360/(2*Pi)))*dPHI)^2))^0.5.
  676.  
  677. set LatATT to (90-(360/(2*Pi))*THETA).
  678. set LongATT to PHI*(360/(2*Pi))-t*(360/BODY:ROTATIONPERIOD).
  679.  
  680. set Coord to list(LatATT,LongATT,t,Vter).
  681.  
  682. return Coord.
  683.  
  684. }
  685.  
  686. function ZoneAttBurn {
  687.  
  688. parameter betaBurn.
  689. parameter DVburn.
  690. parameter Hi.
  691. parameter Tattente.
  692.  
  693. set Pi to 3.14159265359.
  694. set Rc to 8.3144621.
  695.  
  696. set dt to 1.
  697. set t1 to 0.
  698.  
  699.  
  700. // set Vi to SHIP:VERTICALSPEED*cos(VShipPitchO).
  701. // set VShipYawB to arctan2(Vi*sin(VShipYawO)+DVburn*sin(betaBurn),Vi*cos(VShipYawO)+DVburn*cos(betaBurn)).
  702. // set VhoriB to ((Vi^2+DVburn^2-2*Vi*DVburn*cos(VShipYawB))^0.5).
  703. // set VShipPitchB to arctan2(SHIP:VERTICALSPEED,VhoriB).
  704. // set V to (VhoriB^2+SHIP:VERTICALSPEED^2)^0.5.
  705.  
  706.  
  707. set V to SHIP:VELOCITY:ORBIT:MAG.
  708.  
  709. set ImpSpe to ISPCurrent.
  710. set ShipThrust to SHIP:MAXTHRUST*1000.
  711. set Tburn to DeltaTburn(ShipThrust,ImpSpe,DVburn).
  712.  
  713. if DVburn = 0 {
  714. set ShipThrust to 0.
  715. }
  716.  
  717. set Fmp to 0.
  718. set Fmt to 0.
  719.  
  720. set R to SHIP:ALTITUDE+BODY:RADIUS.
  721. set dR to SHIP:VERTICALSPEED.
  722. set PHI to SHIP:LONGITUDE*(2*Pi/360).
  723. set dPHI to (V*cos(VShipPitchO)*sin(VShipYawO))/R.
  724. set THETA to (90-SHIP:LATITUDE)*(2*Pi/360).
  725. set dTHETA to -V*cos(VShipPitchO)*cos(VShipYawO)/R.
  726.  
  727. set Masse to SHIP:MASS*1000.
  728.  
  729. // CLEARSCREEN.
  730. // print "dR: " + round(dR,2) at (0,1).
  731. // print "PHI: " + round(PHI,4) at (0,2).
  732. // print "dPHI: " + round(dPHI,6) at (0,3).
  733. // print "THETA: " + round(THETA,4) at (0,4).
  734. // print "dTHETA: " + round(dTHETA,6) at (0,5).
  735.  
  736. // wait 1.
  737.  
  738. // CLEARSCREEN.
  739.  
  740. set Config:IPU to 2000.
  741.  
  742. set arretMoteur to 0.
  743.  
  744. until R < BODY:RADIUS+Hi or t1 > 25*60 {
  745.  
  746. if t1 = Tattente {
  747.  
  748. set dt to dt/10.
  749.  
  750. set Fmt to -cos(betaBurn)*ShipThrust.
  751.  
  752. set Fmp to sin(betaBurn)*ShipThrust.
  753.  
  754. set q to ShipThrust/(9.81*ImpSpe).
  755.  
  756. // print"dt: " + round(dt,2).
  757. // print"Fmt: " + round(Fmt,2).
  758. // print"Fmp: " + round(Fmp,2).
  759. // print"q: " + round(q,2).
  760.  
  761. }
  762.  
  763. if t1 > Tattente + Tburn and arretMoteur = 0 {
  764.  
  765. set dt to dt*10.
  766.  
  767. set Fmt to 0.
  768.  
  769. set Fmp to 0.
  770.  
  771. set q to 0.
  772.  
  773. set arretMoteur to 1.
  774.  
  775. }
  776.  
  777. if R-Body:Radius < Body:ATM:HEIGHT {
  778.  
  779. set p to (((body:atm:ALTITUDEPRESSURE(R-body:radius)*Constant:AtmToKPa*1000)*(28.9644/1000))/(Rc*220)).
  780. set S to 1.
  781. set Cx to 1.
  782.  
  783. set Ftr to 0.5*p*S*Cx*(dR^2).
  784. set Ftt to 0.5*p*S*Cx*((R*dTHETA)^2).
  785. set Ftp to 0.5*p*S*Cx*((R*sin(THETA*(360/(2*Pi)))*(dPHI-(2*Pi/BODY:ROTATIONPERIOD)))^2).
  786.  
  787. set Vkerb1 to ((dR^2)+((R*dTHETA)^2)+((R*sin(THETA*(360/(2*Pi)))*(dPHI-(2*Pi/BODY:ROTATIONPERIOD)))^2))^0.5.
  788.  
  789. if dR > 0 {
  790. set Ftr to -Ftr.
  791. }
  792. if dTHETA > 0 {
  793. set Ftt to -Ftt.
  794. }
  795. if (dPHI-(2*Pi/BODY:ROTATIONPERIOD)) > 0 {
  796. set Ftp to -Ftp.
  797. }
  798.  
  799. } ELSE {
  800.  
  801. set Ftr to 0.
  802. set Ftt to 0.
  803. set Ftp to 0.
  804.  
  805. }
  806.  
  807. set dRdt to ((-BODY:MU/(R^2))+R*(dPHI^2)*(sin(THETA*(360/(2*Pi)))^2)+R*(dTHETA^2)+(Ftr/Masse))*dt+dR.
  808. set dTHETAdt to (1/R)*(R*(dPHI^2)*sin(THETA*(360/(2*Pi)))*cos(THETA*(360/(2*Pi)))-2*dR*dTHETA+(Ftt/Masse)+(Fmt/Masse))*dt+dTHETA.
  809. set dPHIdt to (1/(R*sin(THETA*(360/(2*Pi)))))*(-2*dR*dPHI*sin(THETA*(360/(2*Pi)))-2*R*dTHETA*dPHI*cos(THETA*(360/(2*Pi)))+(Ftp/Masse)+(Fmp/Masse))*dt+dPHI.
  810.  
  811. set R to dR*dt + R.
  812. set THETA to dTHETA*dt + THETA.
  813. set PHI to dPHI*dt + PHI.
  814.  
  815. set dR to dRdt.
  816. set dPHI to dPHIdt.
  817. set dTHETA to dTHETAdt.
  818.  
  819. if abs(Fmt)>0 or abs(Fmp)>0 {
  820.  
  821. set Masse to Masse-q*dt.
  822.  
  823. }
  824.  
  825. set t1 to t1 + dt.
  826.  
  827. }
  828.  
  829. set Config:IPU to 150.
  830.  
  831. set Vter to ((dR^2)+((R*dTHETA)^2)+((R*sin(THETA*(360/(2*Pi)))*dPHI)^2))^0.5.
  832.  
  833. set LatATT to (90-(360/(2*Pi))*THETA).
  834. set LongATT to PHI*(360/(2*Pi))-t1*(360/BODY:ROTATIONPERIOD).
  835.  
  836. set Coord to list(LatATT,LongATT).
  837.  
  838. return Coord.
  839.  
  840. }
  841.  
  842. function RechercheDeorbitBurn {
  843.  
  844. parameter LatAttisage.
  845. parameter LongAtterisage.
  846. parameter Hl.
  847. parameter DeltaD.
  848. parameter Tattente.
  849.  
  850. set Ddeg to ((LatAttisage-Ship:Latitude)^2+(LongAtterisage-SHIP:Longitude)^2)^0.5.
  851. set Dmin to arccos(BODY:RADIUS/(BODY:RADIUS+SHIP:ALTITUDE))*2.
  852.  
  853. if Ddeg < Dmin {
  854.  
  855. set betburn to VShipYawO+180.
  856. set Vburn to SHIP:VELOCITY:ORBIT:MAG/5.
  857.  
  858. set Vx to Vburn*sin(betburn).
  859. set Vy to Vburn*cos(betburn).
  860.  
  861. set ResultatCoord to ZoneAttBurn(betburn,Vburn,Hl,Tattente).
  862. set LatC to ResultatCoord[0].
  863. set LongC to ResultatCoord[1].
  864. set DistanceAtt to PetiteDistanceCoord(LatC,LongC,LatAttisage,LongAtterisage).
  865.  
  866. set alphaC to 10000. //100m pour 1m/s
  867. set betaC to AnglePetiteCoord(LatC,LongC,LatAttisage,LongAtterisage).
  868.  
  869. // print "Vburn1: " + round(Vburn,2).
  870. // print "betburn1: " + round(betburn,2).
  871. // print "LatC: " + round(LatC,5).
  872. // print "LongC: " + round(LongC,2).
  873. // print "DistanceAtt1: " + round(DistanceAtt,2).
  874.  
  875. until DistanceAtt < DeltaD {
  876.  
  877. set Vx to Vx + (DistanceAtt/(1*alphaC))*sin(betaC).
  878. set Vy to Vy + (DistanceAtt/(1*alphaC))*cos(betaC).
  879.  
  880. set betburn to arctan2(Vx,Vy).
  881. set Vburn to ((Vx^2+Vy^2)^0.5).
  882.  
  883. set ResultatCoord to ZoneAttBurn(betburn,Vburn,Hl,Tattente).
  884.  
  885. set LatCprec to LatC.
  886. set LongCprec to LongC.
  887.  
  888. set LatC to ResultatCoord[0].
  889. set LongC to ResultatCoord[1].
  890.  
  891. set alphaC to PetiteDistanceCoord(LatC,LongC,LatCprec,LongCprec)/(DistanceAtt/alphaC).
  892. set DistanceAtt to PetiteDistanceCoord(LatC,LongC,LatAttisage,LongAtterisage).
  893. set betaC to AnglePetiteCoord(LatC,LongC,LatAttisage,LongAtterisage).
  894.  
  895. // print "BurnCorrectiob:" + round((DistanceAtt/(2*alphaC)),2).
  896. // print "alphaC: "+ round(alphaC,2).
  897. // print "Vburn: " + round(Vburn,2).
  898. // print "betburn: " + round(betburn,2).
  899. // print "LatC: " + round(LatC,3).
  900. // print "LongC: " + round(LongC,3).
  901. print "DistanceAtt(Km): " + round(DistanceAtt/1000,2).
  902.  
  903.  
  904. }
  905.  
  906. return list(Vburn,betburn,DistanceAtt).
  907.  
  908. } ELSE {
  909.  
  910. return list(0,0,0).
  911.  
  912. }
  913.  
  914. }
  915.  
  916. function pair {
  917.  
  918. parameter H.
  919.  
  920. set Rc to 8.3144621.
  921.  
  922. set p to (((body:atm:ALTITUDEPRESSURE(H)*Constant:AtmToKPa*1000)*(28.9644/1000))/(Rc*220)).
  923.  
  924. return p.
  925.  
  926. }
  927.  
  928. function gr {
  929.  
  930. return BODY:MU/((BODY:RADIUS+SHIP:ALTITUDE)^2).
  931.  
  932. }
  933.  
  934. function Moy {
  935.  
  936. parameter NewValeur.
  937. parameter ListAncValeur.
  938. parameter Nmoy.
  939.  
  940. if ListAncValeur:length > Nmoy {
  941.  
  942. ListAncValeur:add(NewValeur).
  943. ListAncValeur:remove(0).
  944.  
  945. } ELSE {
  946.  
  947. ListAncValeur:add(NewValeur).
  948.  
  949. }
  950.  
  951. set Moy1 to 0.
  952.  
  953. for i in range(ListAncValeur:length) {
  954.  
  955. set Moy1 to Moy1 + ListAncValeur[i].
  956.  
  957. }
  958.  
  959. set Moy1 to Moy1/(Nmoy+1).
  960.  
  961. return list(Moy1,ListAncValeur).
  962.  
  963. }
  964.  
  965. function AccSur {
  966.  
  967. set t1 to TIME:SECONDS.
  968. set V1 to SHIP:VELOCITY:SURFACE:MAG.
  969. wait 0.001.
  970. set t2 to TIME:SECONDS.
  971. set V2 to SHIP:VELOCITY:SURFACE:MAG.
  972.  
  973. set AccKerb to (V2-V1)/(t2-t1).
  974.  
  975. return AccKerb.
  976.  
  977. }
  978.  
  979.  
  980. function MaxEnc {
  981.  
  982. parameter Valeur.
  983. parameter Enc.
  984.  
  985. set Valeur to max(Valeur,-Enc).
  986. set Valeur to min(Valeur,Enc).
  987.  
  988. return Valeur.
  989. }
  990.  
  991. function CoordPetiteDistance {
  992.  
  993. parameter Lat1.
  994. parameter Long1.
  995. parameter DistanceaParc.
  996. parameter Diction.
  997.  
  998. set beta to (DistanceaParc/Body:RADIUS)*(180/3.1415).
  999.  
  1000.  
  1001. return list(Lat1+beta*cos(Diction),Long1+beta*sin(Diction)).
  1002. }
  1003.  
  1004. function AnglePetiteCoord {
  1005.  
  1006. parameter LatDepart.
  1007. parameter LongDepart.
  1008. parameter LatArri.
  1009. parameter LongArri.
  1010.  
  1011. set angle to ARCTAN2(LongArri-LongDepart,LatArri-LatDepart).
  1012.  
  1013. if angle < 0 {
  1014.  
  1015. set angle to angle+360.
  1016.  
  1017. }
  1018.  
  1019. return (angle).
  1020.  
  1021. }
  1022.  
  1023. function AnglePetiteCoord180 {
  1024.  
  1025. parameter LatDepart.
  1026. parameter LongDepart.
  1027. parameter LatArri.
  1028. parameter LongArri.
  1029.  
  1030. set angle to ARCTAN2(LongArri-LongDepart,LatArri-LatDepart).
  1031.  
  1032. // if angle < 0 {
  1033.  
  1034. // set angle to angle+360.
  1035.  
  1036. // }
  1037.  
  1038. return (angle).
  1039.  
  1040. }
  1041.  
  1042. function PetiteDistanceCoord {
  1043.  
  1044. parameter Lat1.
  1045. parameter Long1.
  1046.  
  1047. parameter Lat2.
  1048. parameter Long2.
  1049.  
  1050. return ((((Lat1-Lat2)^2+(Long1-Long2)^2)^0.5)*(3.1415/180)*Body:RADIUS).
  1051.  
  1052. }
  1053.  
  1054. function DeltaTburn {
  1055.  
  1056. parameter Fp.
  1057. parameter Ip.
  1058. parameter Dv.
  1059.  
  1060. set g to 9.81.
  1061.  
  1062. set Ve to (g*Ip).
  1063. set q to Fp/(g*Ip).
  1064.  
  1065. set Tb to ((SHIP:MASS*1000)/q)*(1-((2.71828182846)^(-Dv/Ve))).
  1066.  
  1067. return Tb.
  1068. }
  1069.  
  1070. function ISPCurrent {
  1071.  
  1072. LIST ENGINES IN myVariable.
  1073. set I to 0.
  1074. FOR eng IN myVariable {
  1075.  
  1076. set I to I + eng:ISP.
  1077.  
  1078. }
  1079.  
  1080. return ((I/myVariable:LENGTH)).
  1081. }
  1082.  
  1083. function AngleVect {
  1084.  
  1085. parameter Norm1.
  1086. parameter Norm2.
  1087. parameter Arg1.
  1088. parameter Arg2.
  1089.  
  1090. set X1 to cos(Arg1)*Norm1.
  1091. set X2 to cos(Arg2)*Norm2.
  1092. set Y1 to sin(Arg1)*Norm1.
  1093. set Y2 to sin(Arg2)*Norm2.
  1094.  
  1095. set PrdSca to X1*X2+Y1*Y2.
  1096.  
  1097. set angle to arccos(PrdSca/(Norm1*Norm2)).
  1098.  
  1099. return angle.
  1100.  
  1101. }
  1102.  
  1103. function Prime {
  1104.  
  1105. parameter f.
  1106. parameter X1.
  1107. parameter dx.
  1108.  
  1109. return ((f(X1+dx)-f(X1))/dx).
  1110.  
  1111. }
  1112.  
  1113. function VShipPitch {
  1114.  
  1115. return ARCTAN2(SHIP:VERTICALSPEED,SHIP:GROUNDSPEED).
  1116.  
  1117. }
  1118.  
  1119.  
  1120. function ShipPitch {
  1121.  
  1122. set aShipPitch to VANG(ship:up:vector,ship:facing:forevector).
  1123.  
  1124. return (-1)*aShipPitch+90.
  1125.  
  1126. }
  1127.  
  1128. function ShipRoll {
  1129.  
  1130. return VECTORANGLE(UP:VECTOR,SHIP:FACING:STARVECTOR).
  1131.  
  1132. }
  1133.  
  1134.  
  1135. function ShipYaw {
  1136.  
  1137. SET rawyaw TO (-1 * SHIP:BEARING).
  1138.  
  1139. IF rawyaw < 0 {
  1140. SET currentyaw TO (rawyaw + 360).
  1141. } ELSE {
  1142. SET currentyaw TO rawyaw.
  1143. }
  1144.  
  1145. return currentyaw.
  1146.  
  1147. }
  1148.  
  1149.  
  1150. function VShipYaw {
  1151.  
  1152. set VShipYawvec to VectorExclude(SHIP:UP:vector,SHIP:VELOCITY:SURFACE).
  1153. set VShipYawd to VECTORANGLE(SHIP:NORTH:vector,VShipYawvec).
  1154.  
  1155. set vecVersEST to LATLNG(SHIP:LATITUDE,SHIP:LONGITUDE+0.01):POSITION.
  1156. set sign to ((VShipYawvec*vecVersEST)/abs((VShipYawvec*vecVersEST))).
  1157.  
  1158. if sign < 0 {
  1159.  
  1160. set VShipYawd to -VShipYawd + 360.
  1161.  
  1162. }
  1163.  
  1164. return VShipYawd.
  1165.  
  1166. }
  1167.  
  1168. function VShipYaw180 {
  1169.  
  1170. set VShipYawvec to VectorExclude(SHIP:UP:vector,SHIP:VELOCITY:SURFACE).
  1171. set VShipYawd to VECTORANGLE(SHIP:NORTH:vector,VShipYawvec).
  1172.  
  1173. set vecVersEST to LATLNG(SHIP:LATITUDE,SHIP:LONGITUDE+0.01):POSITION.
  1174. set sign to ((VShipYawvec*vecVersEST)/abs((VShipYawvec*vecVersEST))).
  1175.  
  1176. // if sign < 0 {
  1177.  
  1178. // set VShipYawd to -VShipYawd + 360.
  1179.  
  1180. // }
  1181.  
  1182. return VShipYawd.
  1183.  
  1184. }
  1185.  
  1186. function VShipPitchO {
  1187.  
  1188. set aShipPitch to VANG(ship:up:vector,SHIP:VELOCITY:ORBIT).
  1189.  
  1190. return (-1)*aShipPitch+90.
  1191.  
  1192. }
  1193.  
  1194. function VShipYawO {
  1195.  
  1196. set VShipYawvec to VectorExclude(SHIP:UP:vector,SHIP:VELOCITY:ORBIT).
  1197. set VShipYawd to VECTORANGLE(SHIP:NORTH:vector,VShipYawvec).
  1198.  
  1199. set vecVersEST to LATLNG(SHIP:LATITUDE,SHIP:LONGITUDE+0.01):POSITION.
  1200. set sign to ((VShipYawvec*vecVersEST)/abs((VShipYawvec*vecVersEST))).
  1201.  
  1202. if sign < 0 {
  1203.  
  1204. set VShipYawd to -VShipYawd + 360.
  1205.  
  1206. }
  1207.  
  1208. return VShipYawd.
  1209.  
  1210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement