Angle is defined as the degrees of seperation between the spacecraft axis and the horizon. Below is the function used to calculate the angle in radians; it tries to achieve insertion into a low drag orbit with a of minumum energy. The constants within were tweaked with many script runs to achieve low earth orbit at close to a zero angle. However it is imperfect and an improved function would be appreciated.
function getAngle(
inAcceleration,
inAltitude,
inDeceleration,
inFinalAcceleration,
inGravity,
inLowDragAltitude,
inLowDragOrbital,
inXVelocity,
inYVelocity )
{
velocity = sqrt( inXVelocity * inXVelocity + inYVelocity * inYVelocity )
relativeOrbital = velocity / inLowDragOrbital
relativeGravity = 1.05 * inGravity * ( 1.0 - relativeOrbital * relativeOrbital )
timeTill = 2.5 * ( 1.01 * inLowDragOrbital - inXVelocity ) / ( inAcceleration + inFinalAcceleration )
extraTill = inLowDragAltitude - inAltitude - inYVelocity * timeTill
upwardsTill = ( extraTill / timeTill / timeTill ) + relativeGravity
upwards = 0.03 / inG * inDecel * inLowDragOrbital * inLowDragOrbital
upwards += 1.2 * upwardsTill / inAcceleration
if ( velocity > inLowDragOrbital ) {
upwards = 0.0
}
if ( upwards < 0.0 ) {
upwards = 0.0
}
return atan( upwards )
}
This is used in astropolis, spacecraft in vacuum, atmospheric spacecraft, multi stage spacecraft, and spacecraft cost.
Feedback Free Electronic Nation Home Spacecraft GNU Free Documentation License Resume