gravityAssist.frink

Download or view gravityAssist.frink in plain text format


// This program calculates the effect of a gravity-assisted slingshot
// around a planet.  This assumes a hyperbolic path.

// u is the difference in planet speeds at (infinite) distance.  It's also
// known as the hyperbolic excess speed.
u = 13.06 km/s

calculateTransfer[u, jupiterradius, jupitermass]

calculateTransfer[u, planetradius, planetmass] := 
{
   // E is the (constant) energy of the spacecraft per unit mass.
   E = 1/2 u^2

   // h is the angular momentum of the spaceship with respect to the planet.

   // This is the minimum value of h^2.
   hsquaredmin = 2 planetradius^2 (E + (G planetmass / planetradius))

   println["hsquaredmin is $hsquaredmin"]

   // This is the eccentricity of the orbit.
   eccentricity = hsquaredmin / (G planetmass planetradius) - 1

   println["Eccentricity is $eccentricity"]
   
   rmin= (hsquaredmin / (G planetmass)) / (1 + eccentricity)
   println["Planet radius is $planetradius"]
   println["rmin is          $rmin"]

   beta  = 2 arccos[-1 / eccentricity] - pi

   println["Change in angle relative to planet is " + (beta->"degrees")]
}


Download or view gravityAssist.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen, eliasen@mindspring.com