Gravity Engine 12.0
Unity Asset for Gravity
Loading...
Searching...
No Matches
OrbitUtils Class Reference

Classes

class  OrbitElements
 A "struct-like" class that holds all the orbital elements determined by RVtoCOE and used by COEtoRV. There are some specific cases that need to be considered: More...
 

Static Public Member Functions

static float HillRadius (GameObject primary, GameObject secondary)
 Calculates the Hill Radius (radius at which the secondary's gravity becomes dominant, when the secondary is in orbit around the primary).
 
static NBody GetCenterNbody (Transform objectInOrbit, GameObject centerObject)
 Get the center.
 
static Vector3d CenterOfMass (NBody body1, NBody body2)
 
static double CalcAForPeriod (double period, double centerMass)
 Calculate the semi-major axis for the required period.
 
static int CalcKeplerDepth (IFixedOrbit fixedBody)
 Determine how many parents/grandparents etc. have Kepler mode. GE uses this to ensure evolution starts at the most central body in a heirarchy and works out to the leaves.
 
static float SoiRadius (NBody planet, NBody moon)
 Determine the SOI radius in internal physics units.
 
static bool IsOnRails (NBody nbody)
 
static void FindC2C3 (double znew, out double c2new, out double c3new)
 
static double TimeOfFlight (Vector3d r0, Vector3d r1, double p, double mu, Vector3d normal)
 Determine the time of flight in physics time units (GE internal time) that it takes for the body in orbit to go from position r0 to position r1 in an orbit with parameter p.
 
static double TimeOfFlightEllipse (Vector3d r0, Vector3d r1, Vector3d axis, double eccentricity, double orbit_period)
 Simpler approach from Curtis for the case of an ellipse. This handles very large values of r (>1E10) without some of the precision issues that the OrbitUtils.TimeOfFlight has at values near 0, 180 degrees with large r.
 
static OrbitElements RVtoCOE (Vector3 r_in, Vector3 v_in, NBody centerBody, float mu, bool relativePos, double ecc_threshold=small, double incl_threshold=small)
 
static OrbitElements RVtoCOE (Vector3 r_in, Vector3 v_in, NBody centerBody, bool relativePos, double ecc_threshold=small, double incl_threshold=small)
 
static OrbitElements RVtoCOE (Vector3d r_in, Vector3d v_in, NBody centerBody, bool relativePos, double ecc_threshold=small, double incl_threshold=small)
 Pre-4.0 method signature without explicit use of mu.
 
static OrbitElements RVtoCOE (Vector3d r_in, Vector3d v_in, NBody centerBody, double mu, bool relativePos, double ecc_threshold=small, double incl_threshold=small)
 
static void COEtoRV (OrbitElements oe, NBody centerBody, ref Vector3d r, ref Vector3d v, bool relativePos)
 
static void COEtoRVRelative (OrbitElements oe, double mu, ref Vector3d r, ref Vector3d v)
 
static void COEtoRV (OrbitElements oe, NBody centerBody, double mu, ref Vector3d r, ref Vector3d v, bool relativePos, double ecc_threshold=small, double incl_threshold=small)
 
static Vector3d TransformToOrbitFrame (Vector3d v, OrbitElements oe)
 Transform the vector v by the rotation matrix due to the COE.
 
static double PhaseAngleRadiansForDirection (Vector3d pos, OrbitElements oe)
 
static void COEtoRVMirror (OrbitElements oe, NBody centerBody, ref Vector3d r, ref Vector3d v, bool relativePos)
 
static double GetPhaseFromOE (OrbitUtils.OrbitElements oe, double ecc_threshold=small, double incl_threshold=small)
 Returns the current phase in radian.
 
static double FlightPathAngle (double sin_nu, double cos_nu, double ecc)
 Determine the flight path angle. This is the angle from (h x r) to the velocity vector.
 
static bool CheckHitPlanet (double planetRadius, double planetMass, Vector3d r1c, Vector3d v1tc, Vector3d r2c, Vector3d v2tc, int nrev)
 
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 ConvertEtoMeanAnomoly (double eValue, double ecc)
 
static double ConvertTrueAnomolytoE (double nu, double ecc)
 
static double ConvertMeanAnomolyToE (double M, double ecc)
 
static double GsTime (double jdut1)
 
static void LsTime (double lon, double jdut1, out double lst, out double gst)
 
static Vector3 FindNodes (OrbitPredictor ship, OrbitPredictor target)
 

Static Public Attributes

const double small = 1E-3
 
const double verySmall = 1E-9
 
const double ecc_circular = 1E-3
 
static Vector3
 

Member Function Documentation

◆ CalcAForPeriod()

static double OrbitUtils.CalcAForPeriod ( double  period,
double  centerMass 
)
static

Calculate the semi-major axis for the required period.

Parameters
period
centerMass
Returns

◆ ConvertEtoTrueAnomoly()

static double OrbitUtils.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

◆ FlightPathAngle()

static double OrbitUtils.FlightPathAngle ( double  sin_nu,
double  cos_nu,
double  ecc 
)
static

Determine the flight path angle. This is the angle from (h x r) to the velocity vector.

Formulae from the front pages in Vallado.

Parameters
sin_nuSine of the true anaomoly
cos_nuCosine of the true anomoly
eccEccentricity
Returns
Flight Path Angle in Radians

◆ GetCenterNbody()

static NBody OrbitUtils.GetCenterNbody ( Transform  objectInOrbit,
GameObject  centerObject 
)
static

Get the center.

Parameters
objectInOrbit
Returns

◆ GetPhaseFromOE()

static double OrbitUtils.GetPhaseFromOE ( OrbitUtils::OrbitElements  oe,
double  ecc_threshold = small,
double  incl_threshold = small 
)
static

Returns the current phase in radian.

Parameters
oe
Returns

◆ HillRadius()

static float OrbitUtils.HillRadius ( GameObject  primary,
GameObject  secondary 
)
static

Calculates the Hill Radius (radius at which the secondary's gravity becomes dominant, when the secondary is in orbit around the primary).

Returns
The radius.
Parameters
primaryPrimary.
secondarySecondary. In orbit around primary

◆ RVtoCOE()

static OrbitElements OrbitUtils.RVtoCOE ( Vector3d  r_in,
Vector3d  v_in,
NBody  centerBody,
bool  relativePos,
double  ecc_threshold = small,
double  incl_threshold = small 
)
static

Pre-4.0 method signature without explicit use of mu.

Parameters
r_in
v_in
centerBody
relativePos
Returns

◆ SoiRadius()

static float OrbitUtils.SoiRadius ( NBody  planet,
NBody  moon 
)
static

Determine the SOI radius in internal physics units.

Parameters
planet
moon
Returns

◆ TimeOfFlight()

static double OrbitUtils.TimeOfFlight ( Vector3d  r0,
Vector3d  r1,
double  p,
double  mu,
Vector3d  normal 
)
static

Determine the time of flight in physics time units (GE internal time) that it takes for the body in orbit to go from position r0 to position r1 in an orbit with parameter p.

The angle between two 3D vectors cannot be greater than 180 degrees unless the orientation of the plane they define is also specified. The normal parameter is used for this. If an angle less than 180 is desired then the cross product of r0 and v0 can be used as the normal. Calling TOF via the OrbitUniversal wrapper will handle all that automatically.

Parameters
r0from point (with respect to center)
r1to point (with respect to center)
porbit semi-parameter
mucenterbody mass
normalnormal to orital plane
Returns
time to travel from r0 to r1 in GE time

◆ TimeOfFlightEllipse()

static double OrbitUtils.TimeOfFlightEllipse ( Vector3d  r0,
Vector3d  r1,
Vector3d  axis,
double  eccentricity,
double  orbit_period 
)
static

Simpler approach from Curtis for the case of an ellipse. This handles very large values of r (>1E10) without some of the precision issues that the OrbitUtils.TimeOfFlight has at values near 0, 180 degrees with large r.

Parameters
r0
r1
Returns

◆ TransformToOrbitFrame()

static Vector3d OrbitUtils.TransformToOrbitFrame ( Vector3d  v,
OrbitElements  oe 
)
static

Transform the vector v by the rotation matrix due to the COE.

Parameters
v
oe
Returns

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