Gravity Engine 2 3.0
Loading...
Searching...
No Matches
GravityEngine2.Orbital Class Reference

Orbital utilities relating to classical orbital elements (COE) and converting between (r,v) <=> COE. More...

Classes

class  COE
 Classical orbit elements. More...
 
struct  COEStruct
 Light weight struct to hold COE core data for the job system and propagators. More...
 

Public Types

enum  OrbitPoint {
  APOAPSIS , PERIAPSIS , ASC_NODE , DESC_NODE ,
  TRUEANOM_DEG
}
 
enum  OrbitType {
  UNKNOWN , CIRCULAR_EQUATORIAL , CIRCULAR_INCLINED , ELLIPSE_EQUATORIAL ,
  ELLIPSE_INCLINED , HYPERBOLA , FREEFALL
}
 

Static Public Member Functions

static bool CheckHitPlanet (double planetRadius, double planetMass, double3 r1c, double3 v1tc, double3 r2c, double3 v2tc, int nrev)
 
static bool COEEqual (COE coe1, COE coe2, bool includePhase, double sizeTol=1E-2, double angleRadTol=1E-3)
 Determine if two COEs are equal within the indicated tolerances.
 
static double3 COEStructWithPhasetoRVRelative (COEStruct coe, double phaseRad)
 
static double3 double3COEtoRVatTime (COE coe, double time)
 
static double3 COEtoRVRelative (COE oe)
 
static double3 COEWithPhasetoRVRelative (COE oe, double phaseRad)
 
static double ConvertEtoMeanAnomoly (double eValue, double ecc)
 
static double ConvertEtoTrueAnomoly (double eValue, double ecc)
 Convert the eccentric anomaly (angle from center of ellipse wrt x-axis) to the true anomoly (angle from focus wrt periapsis/x-axis if e=0).
 
static double ConvertMeanAnomolyToE (double M, double ecc)
 
static double ConvertMeanToTrueAnomoly (double M, double ecc)
 
static double ConvertTrueAnomolytoE (double nu, double ecc)
 
static void FindC2C3 (double znew, out double c2new, out double c3new)
 Taken from Vallado source code site. (Also used in LambertUniversal) Internal use only.
 
static double GreenwichSiderealTime (double jdut1)
 
static double3 LaunchPlane (double targetInclDeg, double3 r, double latitudeDeg)
 Determine the orbit normal for a launch from an point at the given latitude into an orbit of specified inclination.
 
static double3 OrbitAxis (COE coe)
 Determine the orbit axis (normalized)
 
static double PhaseAngleRadiansForDirection (double3 pos, COE coe)
 Determine the phase in radians for the specified direction. This can be a point on the orbit but this is not required as only the direction of the given vector is used.
 
static double PhaseForOrbitPoint (COE coe, OrbitPoint point, double deg=0)
 Determine the phase for a specific OrbitPoint in an orbit (e.g. APOAPSIS)
 
static double PhaseForRadius (COE coe, double radius)
 Determine phase for a given radius. There are two valid responses, phase and -phase (or 2 Pi - phase). This return +phase.
 
static double3 PositionForCOE (COE coe, double phaseRad)
 Given a COE and phase (radians) determine the relative position in the orbit. The length scale used will match the length scale used in the COE initialization.
 
static double3 PositionsForR (COE coe, double r)
 
static double3 RotateToOrbitFrame (COE coe, double3 r)
 Rotate a 3D vector specified with respect to the default orbit frame (XY orbital plane) into the 3D space where the orientation is adjusted by inclination, omegaU and omegaL.
 
static void RSWState (ref GEBodyState ship, ref GEBodyState planet, double3 orbitNormal, ref GEBodyState rswState)
 Given the state of a ship and planet determine the state info in the RSW frame in which: R is the radial vector to the planet S is along track W is cross track (see Vallado 3.3 p159 (5th ed))
 
static double3 RVForOrbitPoint (COE coe, OrbitPoint point, double deg=0)
 
static COE RVtoCOE (double3 r, double3 v, double mu, double small=1e-6)
 Given state information (r,v) and mu=GM determine the classical orbital elements (COE).
 
static double TimeOfFlight (double3 r0, double3 r1, COE coe)
 Determine the time of flight in COE relevant units that it takes for the body in orbit to go from position r0 to position r1 in an orbit with given COE.
 
static double3 VelocityForCircularOrbitRelative (GEBodyState body, double mu)
 Compute the 3D velocity for a circular velocity for the given 3D body state (r, v) around a mass with specified mu (=GM)
 
static double3 VelocityForCOE (COE coe, double phaseRad)
 Determine the 3D velocity vector for a COE at the specified phase.
 
static bool VelocityIsPrograde (double3 r, double3 v_now, double3 v_next)
 Determine if the given velocities v_now and v_next are both oriented in the same direction around the orbit.
 
static double VelocityMagnitudeForCircular (double r, double mu)
 Determine the magnitude of a circular orbit for a given radius around a body of given mu.
 

Static Public Attributes

static double3
 Determine the two possible 3D positions in an orbit that are at the specified radius.
 
static double3 r
 Determine state from COE and a time from current phase in COE. This used a KeplerPropagator and it might be better to use this approach directly if this will be used more than once.
 
const double SMALL_ANGLE = 1E-3
 
const double SMALL_E = 1E-3
 
const double SMALL_P = 1E-6
 
const double SMALL_SME = 1E-6
 

Detailed Description

Orbital utilities relating to classical orbital elements (COE) and converting between (r,v) <=> COE.

A number of these algorithms originate with Vallado's excellent "Fundamentals of Astrodynamics and Applications" (Microcosm Press) and their adaptations in the original Gravity Engine asset.

There are also some other useful algorithms.

Member Function Documentation

◆ COEEqual()

static bool GravityEngine2.Orbital.COEEqual ( COE coe1,
COE coe2,
bool includePhase,
double sizeTol = 1E-2,
double angleRadTol = 1E-3 )
static

Determine if two COEs are equal within the indicated tolerances.

Phase comparison can be excluded (Useful when getting COE for display orbit, where the phase does not matter)

Parameters
coe1
coe2
includePhase
sizeTol
angleRadTol
Returns

◆ ConvertEtoTrueAnomoly()

static double GravityEngine2.Orbital.ConvertEtoTrueAnomoly ( double eValue,
double ecc )
static

Convert the eccentric anomaly (angle from center of ellipse wrt x-axis) to the true anomoly (angle from focus wrt periapsis/x-axis if e=0).

Equations from front cover of Vallado.

Parameters
eValue
ecc
Returns

◆ FindC2C3()

static void GravityEngine2.Orbital.FindC2C3 ( double znew,
out double c2new,
out double c3new )
static

Taken from Vallado source code site. (Also used in LambertUniversal) Internal use only.

Parameters
znew
c2new
c3new

◆ LaunchPlane()

static double3 GravityEngine2.Orbital.LaunchPlane ( double targetInclDeg,
double3 r,
double latitudeDeg )
static

Determine the orbit normal for a launch from an point at the given latitude into an orbit of specified inclination.

This assumes that a check that inclination > latitude has already been done.

Parameters
targetInclDeg
r
latitudeDeg
Returns
normal to orbit plane

◆ OrbitAxis()

static double3 GravityEngine2.Orbital.OrbitAxis ( COE coe)
static

Determine the orbit axis (normalized)

Parameters
coe
Returns
orbit axis

◆ PhaseAngleRadiansForDirection()

static double GravityEngine2.Orbital.PhaseAngleRadiansForDirection ( double3 pos,
COE coe )
static

Determine the phase in radians for the specified direction. This can be a point on the orbit but this is not required as only the direction of the given vector is used.

Parameters
posdirection relative to the orbit center
coeorbital elements for the orbit
Returns
phase in the specified direction (radians)

◆ PhaseForOrbitPoint()

static double GravityEngine2.Orbital.PhaseForOrbitPoint ( COE coe,
OrbitPoint point,
double deg = 0 )
static

Determine the phase for a specific OrbitPoint in an orbit (e.g. APOAPSIS)

Parameters
coe
point
deg
Returns
phase in radians

◆ PhaseForRadius()

static double GravityEngine2.Orbital.PhaseForRadius ( COE coe,
double radius )
static

Determine phase for a given radius. There are two valid responses, phase and -phase (or 2 Pi - phase). This return +phase.

Parameters
coe
radius
Returns
phase in radians

◆ PositionForCOE()

static double3 GravityEngine2.Orbital.PositionForCOE ( COE coe,
double phaseRad )
static

Given a COE and phase (radians) determine the relative position in the orbit. The length scale used will match the length scale used in the COE initialization.

Parameters
coe
phaseRad
Returns
relative position in orbit

◆ RotateToOrbitFrame()

static double3 GravityEngine2.Orbital.RotateToOrbitFrame ( COE coe,
double3 r )
static

Rotate a 3D vector specified with respect to the default orbit frame (XY orbital plane) into the 3D space where the orientation is adjusted by inclination, omegaU and omegaL.

Parameters
coe
r
Returns
rotated vector

◆ RSWState()

static void GravityEngine2.Orbital.RSWState ( ref GEBodyState ship,
ref GEBodyState planet,
double3 orbitNormal,
ref GEBodyState rswState )
static

Given the state of a ship and planet determine the state info in the RSW frame in which: R is the radial vector to the planet S is along track W is cross track (see Vallado 3.3 p159 (5th ed))

The position vector defines R The orbit normal is used to define the axis for cross track. The cross of R and W defines S.

Parameters
ship
planet
rswState

◆ RVtoCOE()

static COE GravityEngine2.Orbital.RVtoCOE ( double3 r,
double3 v,
double mu,
double small = 1e-6 )
static

Given state information (r,v) and mu=GM determine the classical orbital elements (COE).

Classical orbital elements have inherent singularities for: circular orbits (e=0) flat orbits (i=0 or Pi radians)

In this case the sense of how small is zero is set by the optional parameter small.

In the case of circular orbits there is no closest approach point from which to measure phase nu. For circular orbits the X-axis defines nu=0.

In the case of a flat orbit, there is no ascending node to provide a reference for omegaU. It is set to zero.

See the discussion in the Orbits section of the documentation for other information.

Parameters
r
v
mu
small (optional) threshold for detecting circular/flat orbits
Returns
COE (struct containing orbit elements)

◆ TimeOfFlight()

static double GravityEngine2.Orbital.TimeOfFlight ( double3 r0,
double3 r1,
COE coe )
static

Determine the time of flight in COE relevant units that it takes for the body in orbit to go from position r0 to position r1 in an orbit with given COE.

Parameters
r0from position in orbit
r1to position in orbit
coeCOE struct describing the orbit
Returns
time to move from r0 to r1

◆ VelocityForCircularOrbitRelative()

static double3 GravityEngine2.Orbital.VelocityForCircularOrbitRelative ( GEBodyState body,
double mu )
static

Compute the 3D velocity for a circular velocity for the given 3D body state (r, v) around a mass with specified mu (=GM)

Parameters
bodystruct with r, v state
mucenter body mass
Returns
3D circular velocity vector

◆ VelocityForCOE()

static double3 GravityEngine2.Orbital.VelocityForCOE ( COE coe,
double phaseRad )
static

Determine the 3D velocity vector for a COE at the specified phase.

Parameters
coe
phaseRad
Returns
3D velocity

◆ VelocityIsPrograde()

static bool GravityEngine2.Orbital.VelocityIsPrograde ( double3 r,
double3 v_now,
double3 v_next )
static

Determine if the given velocities v_now and v_next are both oriented in the same direction around the orbit.

This is used in Lambert transfer calculations to select the transfer option that matches the current direction in the orbit

Parameters
rposition in the orbit
v_nowcurrent velocity
v_nextvelocity after possible maneuver
Returns
true if v_next is in same direction as v_now

◆ VelocityMagnitudeForCircular()

static double GravityEngine2.Orbital.VelocityMagnitudeForCircular ( double r,
double mu )
static

Determine the magnitude of a circular orbit for a given radius around a body of given mu.

Parameters
ragnitude of radius
mumu of center body (GM)
Returns

Member Data Documentation

◆ double3

static GravityEngine2.Orbital.double3
static

Determine the two possible 3D positions in an orbit that are at the specified radius.

COEStruct version to determine relative position and velocity for a given COE and phase.

Determine the relative position and velocity for the point in an orbit specified by the COE at the given phase in radians.

Determine the relative R and V for a specified set of classical orbital elements and a GM (mu) for the body at the center of the orbit.

Determine the 3D position and velocity (relative to the center) for the specified type of OrbitPoint.

Parameters
coe
r
Returns
(pos1, pos2) two 3D positions
Parameters
coe
point
deg
Returns
(pos, vel) relative 3D position and velocity
Parameters
oe
mu
Returns
Parameters
oe
phaseRad
Returns
(pos, vel) relative position and velocity

Used in job system (PKEPLER) to determine R, V

Parameters
coe
phaseRad
Returns
(pos, vel) relative position and velocity

◆ r

double3 GravityEngine2.Orbital.r
static

Determine state from COE and a time from current phase in COE. This used a KeplerPropagator and it might be better to use this approach directly if this will be used more than once.

Parameters
coe
time
Returns

The documentation for this class was generated from the following file: