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

Binary Orbit. More...

Inheritance diagram for BinaryOrbit:
OrbitUniversal IOrbitScalable INbodyInit IFixedOrbit IOrbitPositions IOrbitScalable

Public Member Functions

void Start ()
 
void SetupOrbits ()
 
override bool IsOnRails ()
 Check if body is configured at scene start to be fixed. (Allows objects to be optionally configured as not fixed, to allow e.g. Kepler eqn vs initial velocity in OrbitEllipse)
 
override void PreEvolve (float physicalScale, float massScale)
 Called for each NBody object prior to evolution beginning. Allows a chance to setup internal state.
 
override void Evolve (double physicsTime, GravityState gravityState, ref double[] r_new, ref double[] v_new, bool doCallbacks=true)
 In NBody mode, the center of mass NBody will run as a fixed object and determine it's new position each cycle. This ensures that it is up to date when used by OrbitPredictors to show the orbits of the binary pair.
 
double MassForPredictor (NBody nbody)
 Determine the mass to set for an orbit predictor. May be called during OP Start() before Setup has been run, so needs to get nbody info to be safe.
 
override void ApplyScale (float scale)
 Interface to apply the scale to the distance parameter of an orbit.
 
override void ApplyXZChange ()
 
override void InitNBody (float physicalScale, float massScale)
 Inits the N body. Called prior to evolution starting. Allows NBody object to adjust its position and velocity prior to evolution beginning.
 
override string DumpInfo ()
 Create a string with info for display in GEConsole.
 
- Public Member Functions inherited from OrbitUniversal
virtual void InitNBody (float physicalScale, float massScale)
 Inits the N body. Called prior to evolution starting. Allows NBody object to adjust its position and velocity prior to evolution beginning.
 
void InitFromActiveNBody (NBody activeNbody, NBody center, EvolveMode mode)
 Use an active NBody that is live in GE to initialize an orbit.
 
void InitFromJplEphemeris (string data)
 
void InitCOEFromTLEData ()
 Init the classical orbital element (COE) from Celestrak two-line element (TLE) information.
 
string TLEStartEpoch ()
 
void Init ()
 
void Reset ()
 Reset the OrbitPredictor init mode.
 
void SetMajorAxisInspector (double a)
 For ellipses can specify size using major-axis. Typically used by editor script, but may have other uses.
 
double GetMajorAxisInspector ()
 Get the major axis for the orbit using the inspector value (world units).
 
double GetMajorAxis ()
 Get the Major Axis is internal physical units. If the orbit is an ellipse the major axis is valid. If the orbit is a hyperbola, then the value of p will be negative and there is no major axis value.
 
double GetApogeeInspector ()
 Get the apogee (point of greatest distance from focus) for the orbit in Scaled units (e.g. ORBITAL). This is typically used in the inspector prior to the game starting.
 
double GetApogee ()
 Determine the orbit apogee (apoapsis) is internal physics units.
 
double GetSemiParam ()
 
SGP4toGE GetSGP4ToGE ()
 
double GetEnergy ()
 Compute a real-time value for the orbital energy based on (r,v)
 
double GetPerigeeInspector ()
 Get the perigee (point of closest approach to the focus) for the orbit in Scaled units (e.g. ORBITAL). This is typically used in the inspector prior to the game starting.
 
double GetPerigee ()
 Determine the orbit preigee (periapsis) is internal physics units.
 
void SetSizeWithApogeePerigee (double apogee, double perigee)
 Set the size and eccentricity of the ellipse by using values for apogee and perigee. (To be precise really should call them apoapsis and periapsis, but more people will know apogee/perigee).
 
void SetSizeWithEccPerigee (double ecc, double perigee)
 
void SetOrbitPredictor (bool flag)
 
delegate void SGP4ErrorCallback (OrbitUniversal ou, int error)
 In SGP4 propagation the satellite can decay to the point where it should not be propagated. Users may wish to trigger a callback on this event. This allows for a callback to be registered.
 
void AddSGP4ErrorCallback (SGP4ErrorCallback errorCallback)
 Callback for when an SGP4 satellite decays.
 
double GetMu ()
 
void SetMu (double mu)
 Set the mass of the orbit system. This is intended for use when OrbitU is not attached to an NBody e.g. in the case of a DustOrbit.
 
void InitMu ()
 Init the value of mu from the nbody elements. Typically used by OrbitPredictor.
 
NBody GetNBody ()
 
Vector3d GetAxis ()
 Get the normal vector to the orbital plane (normalized).
 
void InitFromOrbitData (OrbitData od, double time)
 Initialize the Orbit from orbital elements contained in an OrbitData object.
 
void CopyFromOrbitUniversal (OrbitUniversal fromOrbit)
 Init from another OrbitUniversal.
 
void InitFromRVT (Vector3d r, Vector3d v, double time, NBody center, bool relativePos, bool updateState=false)
 Initialize the orbit using position, velocity and time.
 
void SetDejitterCOE (bool value)
 
void ReInitForOrbitPredictor (Vector3d r, Vector3d v, double time)
 OrbitPredictor does not need to do a full re-init, just use RV to set new COE.
 
OrbitUtils.OrbitElements.TypeOrbit PredictedOrbitType ()
 When this OrbitU is being used as an orbit predictor report the last type that was determined by the RVtoCOE.
 
void InitFromSolarBody (SolarBody sbody)
 Inits from solar body. This will always be an ellipse.
 
OrbitUtils.OrbitElements GetPKeplerCOE ()
 
virtual void ApplyScale (float scale)
 Interface to apply the scale to the distance parameter of an orbit.
 
virtual void ApplyXZChange ()
 
virtual bool IsOnRails ()
 Check if body is configured at scene start to be fixed. (Allows objects to be optionally configured as not fixed, to allow e.g. Kepler eqn vs initial velocity in OrbitEllipse)
 
virtual void PreEvolve (float physicalScale, float massScale)
 Called for each NBody object prior to evolution beginning. Allows a chance to setup internal state.
 
virtual void Evolve (double physicsTime, GravityState gravityState, ref double[] r_new, ref double[] v_new, bool isQuery=false)
 Evolve the NBody. Implementating method uses physics time and scale to compute the new position, placing it in r. Velocity is also updated so that GetVelocity() can request it if it is of interest.
 
virtual void EvolveSGP4 (double physicsTime, GravityState gravityState, double[] r_new, double[] v_new, bool isQuery=false)
 Evolve using the Simplified General Pertubation propagator model V4.
 
void SetSGP4BlendTime (double time)
 
void LockAtTime (double lockTime)
 Use in On-Rails mode to lock an object at a specific time. Any evolve calls will not re-compute the position/velocity but instead leave them unchanged.
 
void UnlockTime ()
 
Vector3d GetLockedPosVel ()
 
double GetPeriod ()
 
double GetAngularVelocity ()
 
double GetStartTime ()
 
void GetRVT (ref Vector3d r0, ref Vector3d v0, ref double time0)
 Get the intial conditions for the orbit. R0 and V0 are always relative to the center body. If the center is not at (0,0,0) and/or moving, need to adjust values outside.
 
bool RVT_Equal (ref Vector3d r0, ref Vector3d v0, ref double time0, double tol)
 Utility function (used by e.g. OrbitPredictor) to see if the orbit initial conditions have changed. Used to determine when an OP needs to recompute the orbit in KEPLER mode.
 
void GetRVTAbsolute (ref Vector3d r0, ref Vector3d v0, ref double time0)
 
void GEUpdate (GravityEngine ge)
 Perform and update of the world game object position and velocity based on the internal state.
 
void Move (Vector3 position)
 Move in response to a GE.MoveAll() call. (Not called from outside GE).
 
void SetNBody (NBody nbody)
 Set the NBody that the orbit element will evolve. This is not commonly used, since the NBody is typically attached to the same game object as the FixedOrbit. The exception is when fixed orbit segments are part of a KeplerSequence (patched-conic evolution).
 
Vector3[] OrbitPositions (int numPoints, Vector3 centerPos, bool doSceneMapping)
 
Vector3[] OrbitPositions (int numPoints, Vector3 centerPos, bool doSceneMapping, float hyperRadius)
 
Vector3 PositionForPhase (float phaseDeg)
 Get the position for the specified phase in physics co-ordinates.
 
Vector3 VelocityForPhaseRelative (float phaseDeg)
 
Vector3 VelocityForPosition (Vector3 position)
 Given a position on the orbit (or a position that is used to establish a phase wrt the center) determine the velocity vector at that point on the orbit.
 
bool CanApplyImpulse ()
 
NBody GetCenterNBody ()
 Return the center NBody for the fixed orbit.
 
void UpdatePositionAndVelocity (Vector3 pos, Vector3 vel)
 Set a new start position for orbit evolution with respect to the current center object.
 
void SetNewCenter (NBody newCenter)
 Set a new center object. Used when doing Kepler ("on-rails") evolution and the object enters the sphere of influence of a new body. The inital conditions (r0,v0, t0) are updated to be with respect to the new center object allowing Kepler evolution wrt the new center.
 
void ChangeEvolveMode (EvolveMode newMode)
 Change the evolve mode between KEPLER and GRAVITY_ENGINE. i.e. go from off-rails to on-rails.
 
Vector3 ApplyImpulse (Vector3 impulse)
 Apply an impulse to change the on-rails evolution (Kepler or SGP4). OrbitUniversal supports seamless changes from ellipse to parabola to hyperbola. This updates the initial conditions and start time (r0, v0, time0)
 
double TimeOfFlight (Vector3d r0, Vector3d r1)
 Determine the time of flight in physics time units (GE internal time) that it takes for the body in orbit to go from relative position r0 to position r1.
 
double TimeOfFlightEllipse (Vector3d r0, Vector3d r1)
 Find the time of flight from position r0 to r1 when the orbit is elliptical.
 
bool IsCircular ()
 
Quaternion GetConicOrientation ()
 
Vector3[] HyperSegmentSymmetric (int numPoints, Vector3 centerPos, float radiusOrZero, bool doSceneMapping)
 Calculate points suitable for a line renderer that show a segment of the hyperbola for a specified radius with respect to the center.
 
Vector3[] EllipseSegment (int numPoints, Vector3 centerPos, Vector3 pos, Vector3 destPoint, bool shortPath)
 Generate the points for an ellipse segment given the start and end positions. If shortPath then the short path between the points will be shown, otherwise the long way around.
 
Vector3[] EllipseSegmentProRetro (int numPoints, Vector3 centerPos, Vector3 pos, Vector3 destPoint, bool retrograde)
 Generate the points for an ellipse segment given the start and end positions.
 
virtual string DumpInfo ()
 Create a string with info for display in GEConsole.
 
Vector3 GetPositionForThetaRadians (float thetaRadians, Vector3 centerPos)
 Determine orbit position in physics space (with rotation and center offset) for the specified angle in the orbit (in radians)
 
Vector3d GetPositionDForThetaRadians (double thetaRadians, bool relative)
 Determine orbit position in physics space (with rotation and center offset) for the specified angle in the orbit (in radians)
 
Vector3d GetVelocityDForThetaRadians (double theta, bool relative)
 
Vector3[] GetPositionsForRadius (double radius, Vector3 centerPos)
 Get the positions where the orbit is at a specified radius. In general there are two. The result is positions in world space. These can then be used in e.g. TimeOfFlight.
 
float GetPhaseDegForRadius (double radius)
 Get the phase for the specified radius/altitude.
 
OrbitUtils.OrbitElements GetCurrentOrbitalElements ()
 Get the current orbital elements using the live position and velocity from GE.
 
double GetCurrentPhase ()
 Get the current phase (degrees) of the body based on the position and velocity retreived from GE.
 
Vector3[] GetPositionsForRadius (double radius)
 Get the positions where the orbit is at a specified radius. In general there are two. The result is positions in world space. These can then be used in e.g. TimeOfFlight.
 
void SetPositionDouble (Vector3d pos)
 
void InitNBody (float physicalScale, float massScale)
 Inits the N body. Called prior to evolution starting. Allows NBody object to adjust its position and velocity prior to evolution beginning.
 
bool IsOnRails ()
 Check if body is configured at scene start to be fixed. (Allows objects to be optionally configured as not fixed, to allow e.g. Kepler eqn vs initial velocity in OrbitEllipse)
 
void PreEvolve (float physicalScale, float massScale)
 Called for each NBody object prior to evolution beginning. Allows a chance to setup internal state.
 
void Evolve (double physicsTime, GravityState gravityState, ref double[] r, ref double[] v, bool isQuery=false)
 Evolve the NBody. Implementating method uses physics time and scale to compute the new position, placing it in r. Velocity is also updated so that GetVelocity() can request it if it is of interest.
 
void GEUpdate (GravityEngine ge)
 Perform and update of the world game object position and velocity based on the internal state.
 
void Move (Vector3 position)
 Handle dynamic origin shift.
 
void SetNBody (NBody nbody)
 Set the NBody that the orbit element will evolve. This is not commonly used, since the NBody is typically attached to the same game object as the FixedOrbit. The exception is when fixed orbit segments are part of a KeplerSequence (patched-conic evolution).
 
Vector3 ApplyImpulse (Vector3 impulse)
 ApplyImpulse in Kepler mode. (Currently only OrbitUniversal does this)
 
NBody GetCenterNBody ()
 Return the center NBody for the fixed orbit.
 
void UpdatePositionAndVelocity (Vector3 pos, Vector3 vel)
 Update the position and velocity of the object in the orbit.
 
string DumpInfo ()
 Create a string with info for display in GEConsole.
 
Vector3[] OrbitPositions (int numPoints, Vector3 centerPos, bool doSceneMapping)
 
void ApplyScale (float scale)
 Interface to apply the scale to the distance parameter of an orbit.
 
void ApplyXZChange ()
 

Public Attributes

Vector3 initialPosition
 Velocity of center of mass of the binary pair.
 
Vector3 velocity
 
- Public Attributes inherited from OrbitUniversal
EvolveMode evolveMode
 
double p = 10.0
 
double p_inspector = 10.0
 Value of semi-parameter p from inspector (i.e. in GE selected units such as ORBITAL or SOLAR)
 
double eccentricity
 
double inclination
 inclinataion in degrees (0..180)
 
double omega_uc
 Omega in degress (0..360)
 
double omega_lc
 omega in degress (0..360)
 
double phase = 0
 Phase in orbit in degrees.
 
double sgp4_no
 
double sgp4_bstar
 
double pkepler_ndot = 0
 
double pkepler_nddot = 0
 
NBody centerNbody
 Object influencing this bodies motion.
 
InputMode inputMode = InputMode.DOUBLE
 
string jplEphemeris = ""
 
string tleName = ""
 
string tleLine1 =""
 
string tleLine2 =""
 
bool dejitterCOE = false
 
 Vector3d
 

Additional Inherited Members

- Public Types inherited from OrbitUniversal
enum  EvolveMode { GRAVITY_ENGINE , KEPLERS_EQN , SGP4_PROPAGATOR , PKEPLER_J2 }
 Mode for evolution; NBody simulation in GE or "on-rails" using Kepler equation.
 
enum  InputMode {
  DOUBLE , DOUBLE_ELLIPSE , ELLIPSE_MAJOR_AXIS_A , ELLIPSE_APOGEE_PERIGEE ,
  ECC_PERIGEE , TWO_LINE_ELEMENT_SET
}
 
- Protected Member Functions inherited from OrbitUniversal
void CalculateRotation ()
 
- Protected Attributes inherited from OrbitUniversal
Quaternion conic_orientation
 
GravityEngine ge
 

Detailed Description

Binary Orbit.

Configures the initial velocities for two roughly equal masses to establish their elliptical orbits around the center of mass of the pair.

Must have two NBody objects with OrbitUniversal as immediate children.

The BinaryPair object can optionally have a zero-mass NBody and OrbitUniversal component attached. This will be used to determine the initial conditions for the binary pair (position and velocity) so the binary pair can be placed in orbit around another body. This "dummy" NBody is only used during the setup. (It will continue to evolve but there is no model attached and nothing in the scene will be affected by its zero mass.)

Member Function Documentation

◆ ApplyScale()

override void BinaryOrbit.ApplyScale ( float  scale)

Interface to apply the scale to the distance parameter of an orbit.

Parameters
scaleScale.

Implements IOrbitScalable.

◆ ApplyXZChange()

override void BinaryOrbit.ApplyXZChange ( )

Implements IOrbitScalable.

◆ DumpInfo()

override string BinaryOrbit.DumpInfo ( )
virtual

Create a string with info for display in GEConsole.

Returns

Reimplemented from OrbitUniversal.

◆ Evolve()

override void BinaryOrbit.Evolve ( double  physicsTime,
GravityState  gravityState,
ref double[]  r_new,
ref double[]  v_new,
bool  doCallbacks = true 
)
virtual

In NBody mode, the center of mass NBody will run as a fixed object and determine it's new position each cycle. This ensures that it is up to date when used by OrbitPredictors to show the orbits of the binary pair.

If the CM has an OrbitUniversal attached, then it will let that OU move the CM.

Parameters
physicsTime
gravityState
r_new
v_new

Reimplemented from OrbitUniversal.

◆ InitNBody()

override void BinaryOrbit.InitNBody ( float  physicalScale,
float  massScale 
)
virtual

Inits the N body. Called prior to evolution starting. Allows NBody object to adjust its position and velocity prior to evolution beginning.

Parameters
physicalScalePhysical scale.

Reimplemented from OrbitUniversal.

◆ IsOnRails()

override bool BinaryOrbit.IsOnRails ( )
virtual

Check if body is configured at scene start to be fixed. (Allows objects to be optionally configured as not fixed, to allow e.g. Kepler eqn vs initial velocity in OrbitEllipse)

Returns
true if this instance is fixed; otherwise, false.

Reimplemented from OrbitUniversal.

◆ MassForPredictor()

double BinaryOrbit.MassForPredictor ( NBody  nbody)

Determine the mass to set for an orbit predictor. May be called during OP Start() before Setup has been run, so needs to get nbody info to be safe.

Parameters
nbody
Returns

◆ PreEvolve()

override void BinaryOrbit.PreEvolve ( float  physicalScale,
float  massScale 
)
virtual

Called for each NBody object prior to evolution beginning. Allows a chance to setup internal state.

Parameters
physicalScalePhysical scale.
massScaleMass scale.

Reimplemented from OrbitUniversal.


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