Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PARAMETER Targetheight. // Prograde burn only!
- SET SMA TO (APOAPSIS + 600000 + PERIAPSIS + 600000)/2.
- SET SMAF TO (Targetheight + 600000 + APOAPSIS + 600000)/2. // APOAPSIS MAY HAS TO BE CHANGED TO PERIAPSIS!!!!!!
- SET Transfer1 TO SQRT(3531600000000*((2/(APOAPSIS + 600000))-(1/SMA))).
- SET Transfer2 TO SQRT(3531600000000*((2/(APOAPSIS + 600000))-(1/SMAF))).
- print transfer1.
- print transfer2.
- SET APKM TO ROUND(APOAPSIS/1000).
- SET TARKM TO ROUND(Targetheight/1000).
- SET PEKM TO ROUND(PERIAPSIS/1000).
- SET DeltaVneeded TO Transfer2-Transfer1.
- Print (DeltaVneeded) + " DeltaV needed to go into " + TARKM + "Km by " + APKM + "Km orbit".
- HUDTEXT(ROUND(DeltaVneeded) + " DeltaV needed to go into " + TARKM + "Km by " + APKM + "Km orbit, ", 15, 2, 50, WHITE, false).
- //node creation
- SET n to NODE(TIME:SECONDS + ETA:APOAPSIS, 0, 0, DeltaVneeded).
- ADD n.
- SET n TO NEXTNODE.
- LOCK STEERING TO n:BURNVECTOR.
- //calculations of burn time
- SET a0 TO maxthrust / mass.
- SET eIsp TO 0.
- LIST engines IN my_engines.
- FOR eng IN my_engines {
- SET eIsp TO eIsp + eng:maxthrust / maxthrust * eng:isp.
- }
- SET Ve TO eIsp * 9.80665.
- SET final_mass TO mass*CONSTANT():e^(-1*n:BURNVECTOR:MAG/Ve).
- SET a1 TO maxthrust / final_mass.
- SET t TO n:BURNVECTOR:MAG / ((a0 + a1) / 2).
- SET start_time TO TIME:SECONDS + n:ETA - t/2.
- SET end_time TO TIME:SECONDS + n:ETA + t/2 - 1.
- WAIT UNTIL TIME:SECONDS >= start_time.
- LOCK throttle TO 1.
- WAIT UNTIL TIME:SECONDS >= end_time.
- LOCK throttle TO 0.
- // experimental precision
- LOCK STEERING TO PROGRADE.
- if TargetHeight >= apoapsis {
- set throt to 0. // variable to hold current throttle value
- set scalefactor to 1.2. // scalefactor is some value based on the power of your engine
- lock throttle to thrott. // lock the throttle to follow the value of the variable
- until apoapsis >= TargetHeight {
- set thrott to min(((TargetHeight - apoapsis)/Targetheight) * scalefactor, 0.01). // use min to prevent it going completely to zero
- wait 0.01. // wait one tick before recalculating
- }
- lock throttle to 0. // kill throttle
- REMOVE n.
- HUDTEXT("Burn complete, current orbit: " + APKM + "Km by " + PEKM + "Km", 10, 2, 50, WHITE, false).
- unlock steering.
- unlock throttle.
- }
- WAIT 10.
- HUDTEXT ("We are go", 15, 2, 50, WHITE, false).
- //
- //
- //
- // LOOP, CRUCIAL
- //
- //
- //
- SET SMA2 TO (APOAPSIS + 600000 + PERIAPSIS + 600000)/2.
- SET SMAF2 TO (Targetheight + 600000 + APOAPSIS + 600000 + 1000)/2.
- SET Transfer3 TO SQRT(3531600000000*((2/(APOAPSIS + 600000))-(1/SMA2))).
- SET Transfer4 TO SQRT(3531600000000*((2/(APOAPSIS + 600000))-(1/SMAF2))).
- print transfer3.
- print transfer4.
- SET APKM2 TO ROUND(APOAPSIS/1000).
- SET TARKM2 TO ROUND(Targetheight/1000).
- SET PEKM2 TO ROUND(PERIAPSIS/1000).
- SET DeltaVneeded2 TO Transfer4 - Transfer3.
- Print (DeltaVneeded2) + " DeltaV needed to go into " + TARKM2 + "Km by " + APKM2 + "Km orbit".
- HUDTEXT(ROUND(DeltaVneeded2) + " DeltaV needed to go into " + TARKM2 + "Km by " + APKM2 + "Km orbit", 15, 2, 50, WHITE, false).
- //node creation
- SET m to NODE(TIME:SECONDS + ETA:APOAPSIS, 0, 0, DeltaVneeded2).
- ADD m.
- SET m TO NEXTNODE.
- LOCK STEERING TO m:BURNVECTOR.
- //calculations of burn time
- SET a2 TO maxthrust / mass.
- SET eIsp2 TO 0.
- LIST engines IN my_engines.
- FOR eng IN my_engines {
- SET eIsp2 TO eIsp2 + eng:maxthrust / maxthrust * eng:isp.
- }
- SET Ve2 TO eIsp2 * 9.80665.
- SET final_mass2 TO mass*CONSTANT():e^(-1*m:BURNVECTOR:MAG/Ve2).
- SET a3 TO maxthrust / final_mass2.
- SET t2 TO m:BURNVECTOR:MAG / ((a2 + a3) / 2).
- SET start_time2 TO TIME:SECONDS + m:ETA - t2/1.75.
- SET end_time2 TO TIME:SECONDS + m:ETA + t2/2 - 1.
- WAIT UNTIL TIME:SECONDS >= start_time2.
- LOCK throttle TO 1.
- WAIT UNTIL TIME:SECONDS >= end_time2.
- LOCK throttle TO 0.
- if TargetHeight >= periapsis {
- set throt to 0. // variable to hold current throttle value
- set scalefactor to 1.2. // scalefactor is some value based on the power of your engine
- lock throttle to thrott. // lock the throttle to follow the value of the variable
- until periapsis + 200 >= TargetHeight {
- set thrott to min(((TargetHeight - periapsis)/Targetheight) * scalefactor, 0.01). // use min to prevent it going completely to zero
- wait 0.01. // wait one tick before recalculating
- }
- }
- lock throttle to 0. // kill throttle
- remove m.
- unlock steering.
- unlock throttle.
- LOCK STEERING TO PROGRADE.
- AG1 on.
- WAIT 10.
- STAGE.
- WAIT 3.
- LOCK STEERING TO RETROGRADE.
- WAIT 10.
- RUN ACORBIT(88624, 749500).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement