It would appear that Keplerian Orbital Elements are not easily retrievable from the built in expressions (Apoapsis, Periapsis, Eccentricity, and Inclination are useful, but many computations are more easily accomplished with Keplerian elements). So I made a bunch of custom expressions to calculate these for the current craft. Credit for the math: https://space.stackexchange.com/a/1919/34974

!Screenshot: Orbital Parameter Expressions

Example Rocket

Here is the code, you can paste this into your UserData/FlightPrograms/[YOUR PROGRAM NAME].xml file, replace the existing <Expressions /> tag to make these available in your Vizzy Program (NOTE: Apparently SimpleRockets likes to overwrite the new.xml file on load, so putting custom expressions there does not work). Or you can use the example rocket above to save/load a program with these expressions.

UPDATE: Semi-Major Axis calculation now works even when Periapsis is below the surface of the planet.

<Expressions>
<CustomExpression callFormat="Right Ascension" format="Right Ascension return (0)" name="Right Ascension" style="custom-expression" pos="-2330.305,-435.3983">
<Conditional style="conditional">
<Comparison op="l" style="op-lt">
<VectorOp op="y" style="vec-op-1">
<CallCustomExpression call="Node Vector" style="call-custom-expression" />
</VectorOp>
<Constant number="0" />
</Comparison>
<BinaryOp op="-" style="op-sub">
<Constant text="360" />
<CallCustomExpression call="Absolute Right Ascension" style="call-custom-expression" />
</BinaryOp>
<CallCustomExpression call="Absolute Right Ascension" style="call-custom-expression" />
</Conditional>
</CustomExpression>
<CustomExpression callFormat="Absolute Right Ascension" format="Absolute Right Ascension return (0)" name="Absolute Right Ascension" style="custom-expression" pos="-2330.463,-371.8382">
<MathFunction function="rad2deg" style="op-math">
<MathFunction function="acos" style="op-math">
<BinaryOp op="/" style="op-div">
<VectorOp op="x" style="vec-op-1">
<CallCustomExpression call="Node Vector" style="call-custom-expression" />
</VectorOp>
<VectorOp op="length" style="vec-op-1">
<CallCustomExpression call="Node Vector" style="call-custom-expression" />
</VectorOp>
</BinaryOp>
</MathFunction>
</MathFunction>
</CustomExpression>
<CustomExpression callFormat="Node Vector" format="Node Vector return (0)" name="Node Vector" style="custom-expression" pos="-2332.972,-172.8308">
<VectorOp op="cross" style="vec-op-2">
<Constant text="(0,0,1)" />
<CallCustomExpression call="Angular Momentum" style="call-custom-expression" />
</VectorOp>
</CustomExpression>
<CustomExpression callFormat="Angular Momentum" format="Angular Momentum return (0)" name="Angular Momentum" style="custom-expression" pos="-2332.734,-118.5631">
<VectorOp op="cross" style="vec-op-2">
<CallCustomExpression call="Position Z-up" style="call-custom-expression" />
<CallCustomExpression call="Velocity Z-up" style="call-custom-expression" />
</VectorOp>
</CustomExpression>
<CustomExpression callFormat="Argument of Periapsis" format="Argument of Periapsis return (0)" name="Argument of Periapsis" style="custom-expression" pos="-2335.233,-567.1356">
<Conditional style="conditional">
<Comparison op="l" style="op-lt">
<VectorOp op="z" style="vec-op-1">
<CallCustomExpression call="Eccentricity Vector" style="call-custom-expression" />
</VectorOp>
<Constant number="0" />
</Comparison>
<BinaryOp op="-" style="op-sub">
<Constant text="360" />
<CallCustomExpression call="Absolute Argument of Periapsis" style="call-custom-expression" />
</BinaryOp>
<CallCustomExpression call="Absolute Argument of Periapsis" style="call-custom-expression" />
</Conditional>
</CustomExpression>
<CustomExpression callFormat="Absolute True Anomaly" format="Absolute True Anomaly return (0)" name="Absolute True Anomaly" style="custom-expression" pos="-2336.286,-630.1657">
<MathFunction function="rad2deg" style="op-math">
<MathFunction function="acos" style="op-math">
<BinaryOp op="/" style="op-div">
<VectorOp op="dot" style="vec-op-2">
<CallCustomExpression call="Eccentricity Vector" style="call-custom-expression" />
<CallCustomExpression call="Position Z-up" style="call-custom-expression" />
</VectorOp>
<BinaryOp op="" style="op-mul">
<CallCustomExpression call="Eccentricity" style="call-custom-expression" pos="-1264.87,-630.0178" />
<VectorOp op="length" style="vec-op-1">
<CallCustomExpression call="Position Z-up" style="call-custom-expression" />
</VectorOp>
</BinaryOp>
</BinaryOp>
</MathFunction>
</MathFunction>
</CustomExpression>
<CustomExpression callFormat="True Anomaly" format="True Anomaly return (0)" name="True Anomaly" style="custom-expression" pos="-2338.181,-694.319">
<Conditional style="conditional">
<Comparison op="l" style="op-lt">
<VectorOp op="dot" style="vec-op-2">
<CallCustomExpression call="Position Z-up" style="call-custom-expression" />
<CallCustomExpression call="Velocity Z-up" style="call-custom-expression" />
</VectorOp>
<Constant number="0" />
</Comparison>
<BinaryOp op="-" style="op-sub">
<Constant text="360" />
<CallCustomExpression call="Absolute True Anomaly" style="call-custom-expression" />
</BinaryOp>
<CallCustomExpression call="Absolute True Anomaly" style="call-custom-expression" />
</Conditional>
</CustomExpression>
<CustomExpression callFormat="Position Z-up" format="Position Z-up return (0)" name="Position Z-up" style="custom-expression" pos="-2332.435,-8.232553">
<Vector style="vec">
<VectorOp op="x" style="vec-op-1">
<CraftProperty property="Nav.Position" style="prop-nav" />
</VectorOp>
<VectorOp op="z" style="vec-op-1">
<CraftProperty property="Nav.Position" style="prop-nav" />
</VectorOp>
<VectorOp op="y" style="vec-op-1">
<CraftProperty property="Nav.Position" style="prop-nav" />
</VectorOp>
</Vector>
</CustomExpression>
<CustomExpression callFormat="Velocity Z-up" format="Velocity Z-up return (0)" name="Velocity Z-up" style="custom-expression" pos="-2337.234,-62.06971">
<Vector style="vec">
<VectorOp op="x" style="vec-op-1">
<CraftProperty property="Vel.OrbitVelocity" style="prop-velocity" />
</VectorOp>
<VectorOp op="z" style="vec-op-1">
<CraftProperty property="Vel.OrbitVelocity" style="prop-velocity" />
</VectorOp>
<VectorOp op="y" style="vec-op-1">
<CraftProperty property="Vel.OrbitVelocity" style="prop-velocity" />
</VectorOp>
</Vector>
</CustomExpression>
<CustomExpression callFormat="Mu" format="Mu return (0)" name="Mu" style="custom-expression" pos="-1915.278,102.7841">
<BinaryOp op="+" style="op-add">
<BinaryOp op="
" style="op-mul">
<CallCustomExpression call="G" style="call-custom-expression" />
<Constant text="2.38e23" />
</BinaryOp>
<BinaryOp op="" style="op-mul">
<Constant number="0" />
<StringOp op="length" style="length">
<Constant text="// Hard coding Mass of Droo because the planet mass expression is broken" />
</StringOp>
</BinaryOp>
</BinaryOp>
</CustomExpression>
<CustomExpression callFormat="G" format="G return (0)" name="G" style="custom-expression" pos="-1914.548,151.3216">
<Constant text="6.6743e-11" />
</CustomExpression>
<CustomExpression callFormat="Absolute Argument of Periapsis" format="Absolute Argument of Periapsis return (0)" name="Absolute Argument of Periapsis" style="custom-expression" pos="-2333.133,-498.6306">
<MathFunction function="rad2deg" style="op-math">
<MathFunction function="acos" style="op-math">
<BinaryOp op="/" style="op-div">
<VectorOp op="dot" style="vec-op-2">
<CallCustomExpression call="Node Vector" style="call-custom-expression" />
<CallCustomExpression call="Eccentricity Vector" style="call-custom-expression" />
</VectorOp>
<BinaryOp op="
" style="op-mul">
<VectorOp op="length" style="vec-op-1">
<CallCustomExpression call="Node Vector" style="call-custom-expression" />
</VectorOp>
<VectorOp op="length" style="vec-op-1">
<CallCustomExpression call="Eccentricity Vector" style="call-custom-expression" />
</VectorOp>
</BinaryOp>
</BinaryOp>
</MathFunction>
</MathFunction>
</CustomExpression>
<CustomExpression callFormat="Specific Orbital Energy" format="Specific Orbital Energy return (0)" name="Specific Orbital Energy" style="custom-expression" pos="-2337.154,-756.7808">
<BinaryOp op="-" style="op-sub">
<BinaryOp op="/" style="op-div">
<BinaryOp op="^" style="op-exp">
<VectorOp op="length" style="vec-op-1">
<CallCustomExpression call="Velocity Z-up" style="call-custom-expression" />
</VectorOp>
<Constant text="2" />
</BinaryOp>
<Constant text="2" />
</BinaryOp>
<BinaryOp op="/" style="op-div">
<CallCustomExpression call="Mu" style="call-custom-expression" />
<VectorOp op="length" style="vec-op-1">
<CallCustomExpression call="Position Z-up" style="call-custom-expression" />
</VectorOp>
</BinaryOp>
</BinaryOp>
</CustomExpression>
<CustomExpression callFormat="Eccentricity Vector" format="Eccentricity Vector return (0)" name="Eccentricity Vector" style="custom-expression" pos="-2333.573,-236.1447">
<BinaryOp op="/" style="op-div">
<BinaryOp op="-" style="op-sub">
<BinaryOp op="" style="op-mul">
<BinaryOp op="-" style="op-sub">
<BinaryOp op="^" style="op-exp">
<VectorOp op="length" style="vec-op-1">
<CallCustomExpression call="Velocity Z-up" style="call-custom-expression" />
</VectorOp>
<Constant text="2" />
</BinaryOp>
<BinaryOp op="/" style="op-div">
<CallCustomExpression call="Mu" style="call-custom-expression" />
<VectorOp op="length" style="vec-op-1">
<CallCustomExpression call="Position Z-up" style="call-custom-expression" />
</VectorOp>
</BinaryOp>
</BinaryOp>
<CallCustomExpression call="Position Z-up" style="call-custom-expression" />
</BinaryOp>
<BinaryOp op="
" style="op-mul">
<VectorOp op="dot" style="vec-op-2">
<CallCustomExpression call="Position Z-up" style="call-custom-expression" />
<CallCustomExpression call="Velocity Z-up" style="call-custom-expression" />
</VectorOp>
<CallCustomExpression call="Velocity Z-up" style="call-custom-expression" />
</BinaryOp>
</BinaryOp>
<CallCustomExpression call="Mu" style="call-custom-expression" />
</BinaryOp>
</CustomExpression>
<CustomExpression callFormat="Semi-Major Axis" format="Semi-Major Axis return (0)" name="Semi-Major Axis" style="custom-expression" pos="-2339.456,-822.8703">
<Conditional style="conditional">
<Comparison op="l" style="op-lt">
<CallCustomExpression call="Eccentricity" style="call-custom-expression" pos="-2085.436,-811.0436" />
<Constant text="1" />
</Comparison>
<BinaryOp op="" style="op-mul">
<Constant text="-1" />
<BinaryOp op="/" style="op-div">
<CallCustomExpression call="Mu" style="call-custom-expression" />
<BinaryOp op="
" style="op-mul">
<Constant text="2" />
<CallCustomExpression call="Specific Orbital Energy" style="call-custom-expression" />
</BinaryOp>
</BinaryOp>
</BinaryOp>
<BinaryOp op="/" style="op-div">
<Constant text="1" />
<Constant text="4.94065645841247E-324" />
</BinaryOp>
</Conditional>
</CustomExpression>
<CustomExpression callFormat="Inclination" format="Inclination return (0)" name="Inclination" style="custom-expression" pos="-2332.735,-308.722">
<MathFunction function="rad2deg" style="op-math">
<MathFunction function="acos" style="op-math">
<BinaryOp op="/" style="op-div">
<VectorOp op="z" style="vec-op-1">
<CallCustomExpression call="Angular Momentum" style="call-custom-expression" />
</VectorOp>
<VectorOp op="length" style="vec-op-1">
<CallCustomExpression call="Angular Momentum" style="call-custom-expression" />
</VectorOp>
</BinaryOp>
</MathFunction>
</MathFunction>
</CustomExpression>
<CustomExpression callFormat="Eccentricity" format="Eccentricity return (0)" name="Eccentricity" style="custom-expression" pos="-2340.301,-1008.513">
<VectorOp op="length" style="vec-op-1" pos="-2136.861,-1012.096">
<CallCustomExpression call="Eccentricity Vector" style="call-custom-expression" pos="-2120.499,-1006.618" />
</VectorOp>
</CustomExpression>
</Expressions>

Tags
Vizzy

5 Comments

  • Log in to leave a comment
  • Profile image
    Mod sflanker

    Here's another way to get this information: Vizzy++ Mod

    4.0 years ago
  • Profile image
    Mod sflanker

    As I have pointed out here it would be nice to be able to get Keplerian Orbital Elements for an arbitrary node (planet or craft) instead of just the current craft.

    4.0 years ago
  • Profile image
    Mod sflanker

    @Insanity should work now. Simplerockets.com is very wonky some times.

    4.2 years ago
  • Profile image
    10.1k Insanity

    Cool, but the link to the screenshot is broken.

    4.2 years ago
  • Profile image
    Mod sflanker

    I apologize for the poor code block formatting. This forum has a glitch in its markdown processing where it double escapes special characters.

    4.2 years ago

2 Upvotes

Log in in to upvote this post.