-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange_pe_at_ap.ks
More file actions
22 lines (18 loc) · 838 Bytes
/
change_pe_at_ap.ks
File metadata and controls
22 lines (18 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Parameters
parameter target_alt.
local mu is body:mu.
local br is body:radius.
// Current orbit properties
local vom is ship:obt:velocity:orbit:mag. // actual velocity
local r is br + altitude. // actual distance to body
local ra is br + apoapsis. // radius at burn apsis
local v1 is sqrt( vom^2 + 2*mu*(1/ra - 1/r) ). // velocity at burn apsis
local sma1 is (periapsis + 2*br + apoapsis)/2. // semi major axis present orbit
// Desired orbit properties
local r2 is br + apoapsis. // distance after burn at apoapsis
local sma2 is (target_alt + 2*br + apoapsis)/2. // semi major axis target orbit
local v2 is sqrt( vom^2 + (mu * (2/r2 - 2/r + 1/sma1 - 1/sma2 ) ) ).
// Make node
local deltav is v2 - v1.
local nd is node(time:seconds + eta:apoapsis, 0, 0, deltav).
add nd.