Conversion between quantities at periapsis or apoapsis (or at infinity)
[res1, res2...] = CL_kp_apsConvert(type1, val1, type2, val2, output [[, mu]])
Computation of various quantities at periapsis or apoapsis (or at infinity) from other quantities.
The quantities that can be computed are given in output and can be:
- rp: Radius at periapsis.
- ra: Radius at apoapsis (elliptic orbits).
- vp: Velocity at periapsis.
- va: Velocity at apoapsis (elliptic orbits).
- sma: Semi major axis.
- ecc: Eccentricity.
- vinf: Hyperbolic excess velocity (velocity at infinity). It is strictly positive for hyperbolic orbits, %nan otherwise.
type1 and type2 take the same values as given above, but not all combinations are possible. The allowed possibilities are:
- If type1 = "ra" => type2 can be "rp", "vp", "va".
- If type1 = "va" => type2 can be "rp", "ra", "vp".
- If type1 = "rp" => type2 can be "ra", "vp", "va", "vinf".
- If type1 = "vp" => type2 can be "rp", "ra", "va", "vinf".
- If type1 = "sma" => type2 can be "ecc".
Notes:
- If output is "all", all the results are gathered in a structure containing the fields: "sma", "ecc", "ra", "rp", "va", "vp", "vinf".
- No error is raised if rp > ra or va > vp, but ra, rp, va, vp are guaranteed consistent.
For instance the call:
> CL_kp_apsConvert("ra", 7000.e3, "rp", 8000.e3, "va");
will effectively compute the velocity where the radius is ra, although ra actually is the radius at the periapsis.
But also note that this possible inversion of apoapsis and periapsis is not reflected in sma and ecc so that after the two successive calls:
> [sma, ecc] = CL_kp_apsConvert("ra", 7000.e3, "rp", 8000.e3, ["sma", "ecc"]);
> [ra, rp] = CL_kp_apsConvert("sma", sma, "ecc", ecc, ["ra", "rp"]);
ra is 8000.e3 and rp is 7000.e3.
- Undefined output quantities are set to Nan.
- If the excentricity is close to 1 (to within 1.e-8) results are undefined, that is, set to Nan.
(string) Type of 1st quantity - see above for details. (1x1)
Value of 1st quantity. [m or m/s or -] (1xN or 1x1)
(string) Type of 2nd quantity - see above for details. (1x1)
Value of 2nd quantity. [m or m/s or -] (1xN or 1x1)
(string) Names of wanted results - see above for details. (1xP)
(optional) Gravitational constant. Default: %CL_mu. [m^3/s^2] (1x1)
Results. [m or m/s or -] (1xN)
CNES - DCT/SB
// Example 1 sma = 7.e6; ecc = 1.e-2; // Computes ra and rp from sma and ecc [ra, rp] = CL_kp_apsConvert("sma", sma, "ecc", ecc, ["ra", "rp"]) // Computes everything from ra and rp res = CL_kp_apsConvert("ra", ra, "rp", rp, "all") // Example 2: Hohmann transfer r1 = 7.e6; r2 = 8.e6; v1 = CL_kp_apsConvert("rp", r1, "ra", r1, ["vp"]); v2 = CL_kp_apsConvert("rp", r2, "ra", r2, ["vp"]); [vp, va] = CL_kp_apsConvert("rp", r1, "ra", r2, ["vp", "va"]); dv_hohmann = (vp - v1) + (v2 - va); dv_hohmann - CL_man_dvHohmann(r1, r2) // => 0 // Example 3 // Note that rp can be greater or smaller than ra ra = 8.e6; rp = ra + (-1 : 0.1 : 1) * 1.e6; vp = CL_kp_apsConvert("rp", rp, "ra", ra, ["vp"]); scf(); plot(rp / 1000, vp); | ![]() | ![]() |