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

Gravity Engine Core Central class for evolution using gravity and propagators. More...

Classes

struct  GEConfig
 

Public Types

enum  BodyType {
  MASSIVE_G , MASSLESS_G , FIXED , KEPLER_MASSIVE1 ,
  KEPLER_MASSIVE2 , KEPLER_MASSIVE3 , KEPLER_MASSLESS , SGP4 ,
  PKEPLER , EPHEMERIS , UNUSED
}
 
enum  ReferenceFrame { INERTIAL , COROTATING_CR3BP }
 

Public Member Functions

 GECore (GECore ge, bool copyCallbacks=false)
 COPY CONSTRUCTOR Create a new GE as a clone of an existing GE.
 
 GECore (Integrators.Type integrator, GBUnits.Units defaultUnits, CR3BP.CR3BPSystemData cr3bpSystem, double stepsPerOrbit, double startTimeJD)
 Construct a GECore to perform evolution in the circular-restricted three body coordinate system (CR3BP). In this system the primary and secondary bodies are fixed and the equations of evolution model gravity and include terms to account for the rotating frame.
 
 GECore (Integrators.Type integrator, GBUnits.Units defaultUnits, double lengthScale, double massScale, double stepsPerOrbit, double startTimeJD=0)
 Construct a GECore to evolve bodies. The majority of the parameters relate to the scaling to be configured for numerical integration. Generally the information in/out is expressed in the defaultUnits (world units). The numerical integration is best when "typical values" of mass and length are of order 1. Internally physical parameters are scaled to obtain this.
 
ref GEPhysicsCore.GEBodies BodiesGetAll ()
 
int BodyAdd (double3 rWorld, double3 vWorld, double massWorld=0, bool isFixed=false)
 Adding Bodies.
 
int BodyAddInOrbitWithCOE (Orbital.COE coeWorld, int centerId, GEPhysicsCore.Propagator prop, double massWorld=0.0, bool isPatched=false, double time_patch_start=0.0)
 Add a body in orbit relative to a center body using COE (classical orbital elements, a, eccentricy, inclination etc.)
 
int BodyAddInOrbitWithRVRelative (double3 rWorld, double3 vWorld, int centerId, GEPhysicsCore.Propagator prop, double massWorld=0.0, bool isPatched=false, double time_patch_start=0.0)
 Add a body by specifying state relative to a second body. Typically this is used to place a body in orbit around a body when the specific R, V is known.
 
int BodyAddInOrbitWithTLE (string tleData, int centerId, GEPhysicsCore.Propagator prop, bool isPatched=false, double time_patch_start=0.0)
 Add a body in orbit around Earth (only Earth!) using a two-line element data structure.
 
int BodyAddWithEphemeris (EphemerisData ephemData, int cid, double m, bool isPatched=false, double time_patch_start=0.0)
 Add a body with a table of ephemeris data (a table of position and velocity at future times). Some websites (JPL) and third-party software tools can emit an ephemeris table.
 
bool BodyRemove (int id)
 Remove a body from GECore.
 
BodyType BodyTypeById (int id)
 Get the type of the body. Does not change at run time, so ok to just return it now.
 
Orbital.COE COE (int bodyId, int centerId, bool usePropCOE=true)
 Get the classical orbital elements (COE) for the indicated body with respect to the center body.
 
void ColliderAddToBody (int id, double radius, double bounceF, GEPhysicsCore.CollisionType collisionType, double mass)
 Add collision detection to a body. This results in the GEPhysicsCore performing comparisions to other bodies that habve collision detection enabled.
 
void Complete ()
 Signal that jobs running must complete and wait for this to happen.
 
void Dispose ()
 
double Dt ()
 Numerical integration timestep value.
 
void DtSet (double dt)
 Configure the internal timestep used in numerical integration.
 
string DumpAll (string info="", bool worldScale=false)
 
void EvolveNow (double tUntilWorld)
 
void EvolveNowRecordOutput (double tUntilWorld, NativeArray< double > timePoints, NativeArray< int > bodies)
 Evolve the gravitational system in-line (may take more that one frame depending on the t_until) and record the state of the bodies described in bodies at the times in timePoints.
 
int ExternalAccelerationAdd (int bodyId, ExternalAccel.ExtAccelType eaType, ExternalAccel.AccelType accelType, double3[] accelData=null)
 An external acceleration function can be added to a body. This acceleration may be a "self-force" (e.g. thrust from an ion drive) or a force from this bodyId to other bodies (e.g. the J2 force due to a non-spherical planet). This is specified by the eaType (SELF or ON_OTHER).
 
double3[] ExternalAccelerationData (int extAccelId)
 Return a copy of the external acceleration params.
 
int ExternalAccelerationDataOffset (int extAccelId)
 
void ExternalAccelerationDataUpdate (int extAccelId, double3[] data)
 Update the external acceleration parameters for a specific external acceleration.
 
void ExternalAccelerationRemove (int extAccelId)
 Remove the external acceleration.
 
GBUnits.GEScaler GEScaler ()
 
double GetParm (int index)
 Get information from the GE physics config.
 
GECore GeTrajectory ()
 
bool IsCompleted ()
 Poll to see if the jobs that were scheduled are complete.
 
bool IsRunning ()
 Determine if GECore is currently running a physical loop.
 
void ListenerAdd (GEListenerIF geListener)
 Add a listener.
 
void ManeuverAdd (int id, GEManeuver m, double timeOffsetWorldTime=double.NaN)
 Add a maneuver to the list of pending maneuvers. If no timeOffset is given it is assumed the t_relative in the maneuver is to be added to the current time to establish the overall maneuver time.
 
List< int > MassiveIndicesGet ()
 
double MassWorld (int id)
 Return mass for a specified object.
 
double MuWorld (int id)
 Return G * world mass for the body id given.
 
int NumBodies ()
 Return the total number of bodies in GE (of all types)
 
int NumRecordedBodies ()
 Number of bodies active in recording function.
 
bool OnRails ()
 Determine if all bodies are using deterministic propagators aka all "On Rails". Conversly ensure no bodies are evolving using numerical integration of gravitational forces.
 
double OrbitPeriodWorldTime ()
 Provide the time for one period of the reference (scale) orbit in world time units.
 
void PatchAddToBody (int id, double3 r, double3 v, int centerId, GEPhysicsCore.Propagator prop, double time_start, double time_end=-1.0, double mass=0.0)
 Add a patch specified via R, V, T at the indicated start time.
 
void PatchAddToBody (int id, Orbital.COE oe, int centerId, GEPhysicsCore.Propagator prop, double time_start, double time_end=-1.0, double mass=0.0)
 Add a patch specified via classical orbital elements (COE) at the indicated start time.
 
void PhyLoopCompleteCallbackAdd (PhysLoopCompleteCallback cb, object arg=null)
 Add a callback to be invoked when GE physics loop completes running.
 
delegate void PhysicsEventCallback (GECore ge, GEPhysicsCore.PhysEvent physEvent)
 
void PhysicsEventListenerAdd (PhysicsEventCallback physEventCB)
 
void PhysicsEventListenerRemove (PhysicsEventCallback physEventCB)
 
ref GEPhysicsCore.GEPhysicsJob PhysicsJob ()
 Get a reference to the GEPhysicsJob.
 
delegate void PhysLoopCompleteCallback (GECore ge, object arg=null)
 The most flexible way to ask GE to do things is via a callback when the physics loop is complete. This allows the scene to toggle between IMMEDIATE modes and job mode without code changes. When in immediate mode the callbacks are not stored and immediatly run.
 
void PreCalcIntegration ()
 Call prior to beginning evolution in case integrator needs to set up internal info.
 
void PropagateToTime (double tWorld, int id, ref GEBodyState state)
 Using the propagator for the ID propagate to the requested time and fill in the state struct with the R, V at that time.
 
GEPhysicsCore.Propagator PropagatorTypeForId (int id)
 Return the propagator type for the specified id.
 
NativeArray< int > RecordedBodies ()
 
NativeArray< GEBodyStateRecordedOutputGEUnits ()
 Get a reference to the recorded output in GE units.
 
NativeArray< double > RecordedTimesGEUnits ()
 
ReferenceFrame RefFrame ()
 
bool RelativeState (int bodyId, int centerId, ref GEBodyState bodyState, bool geUnits=false)
 Provide the state of a body relative to another body (typically the center body which the first body orbits.
 
void RepositionAll (double3 r_offest)
 Apply a position and velocity transformation to all states.
 
double3 RWorldById (int id)
 Get the world position of a body of specified id.
 
void Schedule (double tUntilWorld)
 Schedule the job to run until t_until. Do this in a way that the job can be continued with subsequent schedule calls.
 
void ScheduleRecordOutput (double tUntilWorld, NativeArray< double > timePoints, NativeArray< int > bodies)
 Run GE evolution in "batch" mode and record the output at specified timePoints for the indicated bodies.
 
bool StateById (int id, ref GEBodyState state, bool geUnits=false, bool maintainCoRo=false)
 Fill in a state using the id (unique to this GE). The state is at the current world time. Note that the current world time may slightly exceed the time that was requested in the preceeding Evolve() or Schedule() due to the finite step sixe in the numerical integration.
 
bool StateByIdInterpolated (int id, ref GEBodyState state, double atTime, bool geUnits=false)
 Determine the state at a time that is slightly earlier than the current world time.
 
bool StateSetById (int id, GEBodyState s, bool velocityOnly=false, bool relative=false, bool geUnits=false)
 
double TimeGE ()
 Time in internal GECore units.
 
double TimeJulianDays ()
 Time expressed as Julian days.
 
double TimeWorld ()
 Time in world units (defaultUnits when GEC was created).
 
bool TimeWorldSet (double worldTime)
 Set the world time.
 
void TrajectoryRemove (int bodyId)
 Remove a trajectory from the trajectory recording. This will not require a trajectory reset so it can be done without too much fuss.
 
void TrajectorySetup (double t_ahead, int numSteps, List< int > bodiesToRecord)
 Configure this GE to evolve forward by "timeAhead" recording positions at intervals of timeAhead/numSteps.
 

Public Attributes

Integrators.Type integrator
 

Static Public Attributes

const double DT_DEFAULT = 2.0 * math.PI / 500.0
 
const int DT_PARAM = 0
 
const int NUM_PARAMS = 9
 
const int START_TIME_JD = 8
 
const int T_END_JD = 3
 
const int T_END_PARAM = 2
 
const int T_PARAM = 1
 
const int TRAJ_INDEX_PARAM = 4
 
const int TRAJ_INTERVAL_PARAM = 7
 
const int TRAJ_NUM_UPDATED_PARAM = 6
 
const int TRAJ_NUMSTEPS_PARM = 5
 

Detailed Description

Gravity Engine Core Central class for evolution using gravity and propagators.

Handles:

  • evolution directly or as a job
  • management of physics data structures for bodies, maneuvers, patches etc.
  • handles body additions with a variety of initial conditions (RV, COE, ephemeris, TLE etc.)
  • the physics evolution is handed to
    See also
    GEPhysicsCore
    This class can be used directly or
    See also
    GSController will instantiate a instance.
    Since execution may be via the Unity job system a large part of what GECore does is to arrange data into arrays suitable for use in the job system. This aids in memory locality and speed. Hence there are often parallel data stores for info in GECore as lists and then an array version of the info for GEPhysicsCore.

Constructor & Destructor Documentation

◆ GECore() [1/3]

GravityEngine2.GECore.GECore ( Integrators::Type integrator,
GBUnits::Units defaultUnits,
double lengthScale,
double massScale,
double stepsPerOrbit,
double startTimeJD = 0 )

Construct a GECore to evolve bodies. The majority of the parameters relate to the scaling to be configured for numerical integration. Generally the information in/out is expressed in the defaultUnits (world units). The numerical integration is best when "typical values" of mass and length are of order 1. Internally physical parameters are scaled to obtain this.

Parameters
integratorspecify numerical inegration scheme
defaultUnits
lengthScalelength in world units that will be 1 physics unit
massScalemass in world units that will be 1 mass unit
stepsPerOrbitsuggested number of time steps per circular orbit of radius lengthScale
startTimeJDstart time in Julian date format (only needed when satellite info in TLEs)

◆ GECore() [2/3]

GravityEngine2.GECore.GECore ( Integrators::Type integrator,
GBUnits::Units defaultUnits,
CR3BP::CR3BPSystemData cr3bpSystem,
double stepsPerOrbit,
double startTimeJD )

Construct a GECore to perform evolution in the circular-restricted three body coordinate system (CR3BP). In this system the primary and secondary bodies are fixed and the equations of evolution model gravity and include terms to account for the rotating frame.

This constructor explcitly adds the primary and secondary bodies based on the information in the cr3bpSystem parameter.

Parameters
integrator
defaultUnits
cr3bpSystem
stepsPerOrbit
startTimeJD
Exceptions
NotSupportedException

◆ GECore() [3/3]

GravityEngine2.GECore.GECore ( GECore ge,
bool copyCallbacks = false )

COPY CONSTRUCTOR Create a new GE as a clone of an existing GE.

  • the clone will have the same id mapping for bodies and internal structure
  • NotRunningCallbacks may optionally NOT be copied (since likely want to attach new ones)
Parameters
ge
copyCallbacks

Member Function Documentation

◆ BodiesGetAll()

ref GEPhysicsCore.GEBodies GravityEngine2.GECore.BodiesGetAll ( )
Returns

◆ BodyAdd()

int GravityEngine2.GECore.BodyAdd ( double3 rWorld,
double3 vWorld,
double massWorld = 0,
bool isFixed = false )

Adding Bodies.

Add a body with absolute world R, V, mass state information to GE with world information expressed in the defaultUnits specified in the GECore constructor.

There is no general propagator choice in this case because all the propagators are relative to some center body. To add with a propagtor use one of the BodyAddInOrbitWithRVRelative or BodyAddInOrbitWithCOE methods. are relative to some center body. To add with a propagator use one of

See also
BodyAddInOrbitWithRVRelative
BodyAddInOrbitWithCOE
BodyAddInOrbitWithTLE
Parameters
rWorldposition in World default units
vWorldvelocity in World default units
massWorldworld mass (may be zero)
isFixed(optional) body is fixed and will not be moved by GE
Returns

◆ BodyAddInOrbitWithCOE()

int GravityEngine2.GECore.BodyAddInOrbitWithCOE ( Orbital::COE coeWorld,
int centerId,
GEPhysicsCore::Propagator prop,
double massWorld = 0::0,
bool isPatched = false,
double time_patch_start = 0::0 )

Add a body in orbit relative to a center body using COE (classical orbital elements, a, eccentricy, inclination etc.)

For patching information see comments in BodyAddInOrbitWithRVRelative

Parameters
coeWorldorbit elements in default units
centerIdid of center body of orbit
proppropagator
massWorldmass of body to add
isPatchedupdates to this body as patches
time_patch_starttime patches start
Returns

◆ BodyAddInOrbitWithRVRelative()

int GravityEngine2.GECore.BodyAddInOrbitWithRVRelative ( double3 rWorld,
double3 vWorld,
int centerId,
GEPhysicsCore::Propagator prop,
double massWorld = 0::0,
bool isPatched = false,
double time_patch_start = 0::0 )

Add a body by specifying state relative to a second body. Typically this is used to place a body in orbit around a body when the specific R, V is known.

To put a body in orbit using orbit parameters BodyAddInOrbitWithCOE

Patching: Bodies that have deterministic (i.e. no numerical integration) propagators are candidates to be "patched". A patched body records subsequent changes in state (r, v) by appending a propagator segment to the body. The patch has an associated start and end time and the evolution code uses the patch corresponding to the current time.

Patching is typically used to either:

  • handle a maneuver sequence in a way that allows time to be jumped forward or backward
  • implement a sequence of orbital propagators (aka conics) to model movement from one gravity system to another where only one system at a time exerts a gravitational force.
Parameters
rWorldrelative position in default units
vWorldrelative velocity in default units
centerIdbody id of center body
proppropagator type
massWorldmass of object to add
isPatchedsubsequent changes should be added as patches
time_patch_starttime of first patch
Returns

◆ BodyAddInOrbitWithTLE()

int GravityEngine2.GECore.BodyAddInOrbitWithTLE ( string tleData,
int centerId,
GEPhysicsCore::Propagator prop,
bool isPatched = false,
double time_patch_start = 0::0 )

Add a body in orbit around Earth (only Earth!) using a two-line element data structure.

Earth satellite information is often expressed in a two-line forms (e.g. celestrak.com) which harkens back to two 80 column punch cards (some API choices are "sticky"!).

Use of this method requires that the center body have the mass of the Earth. It also requires that the start time of the GECore in Julian days has been configured. Satellite data provides the orbit information at a specific date/time and this time must be earlier than the start time of GECore.

For patching information see comments in BodyAddInOrbitWithRVRelative

Parameters
tleDatastring representing the two line element info
centerIdid of center body
proppropagator
isPatchedhandle updates to state as patches
time_patch_start
Returns

◆ BodyAddWithEphemeris()

int GravityEngine2.GECore.BodyAddWithEphemeris ( EphemerisData ephemData,
int cid,
double m,
bool isPatched = false,
double time_patch_start = 0::0 )

Add a body with a table of ephemeris data (a table of position and velocity at future times). Some websites (JPL) and third-party software tools can emit an ephemeris table.

Ephemeris data is wrapped in a class.

For patching information see comments in BodyAddInOrbitWithRVRelative

Parameters
ephemDataephemeris data
cidcenter body
mmass of body
isPatchedhandle updates as patches
time_patch_start
Returns

◆ BodyRemove()

bool GravityEngine2.GECore.BodyRemove ( int id)

Remove a body from GECore.

Parameters
id

◆ BodyTypeById()

BodyType GravityEngine2.GECore.BodyTypeById ( int id)

Get the type of the body. Does not change at run time, so ok to just return it now.

Parameters
id
Returns

◆ COE()

Orbital.COE GravityEngine2.GECore.COE ( int bodyId,
int centerId,
bool usePropCOE = true )

Get the classical orbital elements (COE) for the indicated body with respect to the center body.

The most common way to do this is to take the R, V state of the body and use an algorithm (RVtoCOE) to determine the COE elements. This algorithm imposes a choice of when an orbit is to be considered flat or circular.

A flat orbit (i=0) has it's OmegaU/RAAN set to 0. A circular orbit has it's argp set to zero (this is the reference point for the phase, nu).

Of course the zero detect is not exactly zero, so there will be some threshold (usually E-6) where e.g. an orbit can transition from flat to non-flat. When this happens the argp and phase may have a discontinuity (athough their sum will remain constant).

Parameters
bodyId
centerId
usePropCOEIf propagator has internal COE, use that instead of recomputing from R, V
Returns

◆ ColliderAddToBody()

void GravityEngine2.GECore.ColliderAddToBody ( int id,
double radius,
double bounceF,
GEPhysicsCore::CollisionType collisionType,
double mass )

Add collision detection to a body. This results in the GEPhysicsCore performing comparisions to other bodies that habve collision detection enabled.

Collision detection is performed by checking if the separation of the bodies is less than the sum of their radii (ie. as if there were spherical colliders).

This collision detection is internal to GECore and is not related to the Unity physics collision detection system.

The mass provided to the collision system is not necessarily the same as the gravitational mass. For example it makes sense to treat a satellite as having zero gravitational mass (so force of satellite on Earth is not computed) but for the purpose of a collision a mass e.g. 2000 kg is appropriate.

Parameters
idbody id
radiusspherical size of this body in default World units
bounceFbounce factor for elastic collisions
collisionTypeinteraction type (absorb/bounce)
massinertial mass

◆ Complete()

void GravityEngine2.GECore.Complete ( )

Signal that jobs running must complete and wait for this to happen.

If a trajectory job is also being used, this will complete also.

◆ Dt()

double GravityEngine2.GECore.Dt ( )

Numerical integration timestep value.

Returns

◆ DtSet()

void GravityEngine2.GECore.DtSet ( double dt)

Configure the internal timestep used in numerical integration.

Parameters
dt

◆ DumpAll()

string GravityEngine2.GECore.DumpAll ( string info = "",
bool worldScale = false )
Parameters
info
worldScale
Returns

◆ EvolveNow()

void GravityEngine2.GECore.EvolveNow ( double tUntilWorld)
Parameters
tUntilWorld

◆ EvolveNowRecordOutput()

void GravityEngine2.GECore.EvolveNowRecordOutput ( double tUntilWorld,
NativeArray< double > timePoints,
NativeArray< int > bodies )

Evolve the gravitational system in-line (may take more that one frame depending on the t_until) and record the state of the bodies described in bodies at the times in timePoints.

The result is placed in a large linear NativeArray indexed as: timePointNum * numBodies +

Parameters
t_until
timePoints
bodies

◆ ExternalAccelerationAdd()

int GravityEngine2.GECore.ExternalAccelerationAdd ( int bodyId,
ExternalAccel::ExtAccelType eaType,
ExternalAccel::AccelType accelType,
double3[] accelData = null )

An external acceleration function can be added to a body. This acceleration may be a "self-force" (e.g. thrust from an ion drive) or a force from this bodyId to other bodies (e.g. the J2 force due to a non-spherical planet). This is specified by the eaType (SELF or ON_OTHER).

The return value is an index to the external acceleration. Updates to the acceleration parameters require a reference to the external acceleration. (A given body ID may have more that one external acceleration e.g. rocket engine and atmospheric drag).

The application of the acceleration takes place in the depths of GEPhysicsCore numerical integration and this may use the Job system: Consequently

  • any parameter information must be presented as a block of double3[].
  • function pointers are not permitted [*]. Any user defined forces will require an extension in
    See also
    ExtAccelFactory
    Each function can take a block of double3[] as parameters and scratch memory.

[*] technically an unsafe function pointer can be used, but the Asset Store does not permit assets to declare unsafe code.

Parameters
bodyIdidentity of body to compute external acceleration
eaTypetype of force (self/on-other)
accelTypeenumerated type to slect force
accelDataparameters for force calculation
Returns
id for the acceleration

◆ ExternalAccelerationData()

double3[] GravityEngine2.GECore.ExternalAccelerationData ( int extAccelId)

Return a copy of the external acceleration params.

Parameters
extAccelIdthe id of the external acceleration (NOT bodyId!)
Returns

◆ ExternalAccelerationDataUpdate()

void GravityEngine2.GECore.ExternalAccelerationDataUpdate ( int extAccelId,
double3[] data )

Update the external acceleration parameters for a specific external acceleration.

Parameters
extAccelId
data

◆ ExternalAccelerationRemove()

void GravityEngine2.GECore.ExternalAccelerationRemove ( int extAccelId)

Remove the external acceleration.

Parameters
extAccelId

◆ GEScaler()

GBUnits.GEScaler GravityEngine2.GECore.GEScaler ( )

Get the GEScalar. Used when code needs to determine conversions from physics space (GEC internal) to world units.

Returns
GEScalar

◆ GetParm()

double GravityEngine2.GECore.GetParm ( int index)

Get information from the GE physics config.

Parameters
index
Returns

◆ IsCompleted()

bool GravityEngine2.GECore.IsCompleted ( )

Poll to see if the jobs that were scheduled are complete.

Returns

◆ IsRunning()

bool GravityEngine2.GECore.IsRunning ( )

Determine if GECore is currently running a physical loop.

Returns

◆ ListenerAdd()

void GravityEngine2.GECore.ListenerAdd ( GEListenerIF geListener)

Add a listener.

Currently used to get a callback when a body is removed due to a collision.

Parameters
geListener

◆ ManeuverAdd()

void GravityEngine2.GECore.ManeuverAdd ( int id,
GEManeuver m,
double timeOffsetWorldTime = double::NaN )

Add a maneuver to the list of pending maneuvers. If no timeOffset is given it is assumed the t_relative in the maneuver is to be added to the current time to establish the overall maneuver time.

If an explicit timeOffset is provided, use it.

If the body the maneuver is being applied to is patched, and the maneuver has isPatched then instead of adding a maneuver we can add a patch. It is assumed that maneuvers for a given id are added in increasing time order. (Note: GEPhysicsJob cannot easily create a patch "on the fly" since it would need to dynamically change it's data structures and let GE know. This could be solved but defer for now).

Note that the GEManeuver instances are kept in GE but must be converted into a GEManeuverStruct for the IJob (it cannot handle classes).

Life Cycle: Maneuvers are added to pendingManeuvers. GECore then copies this list of manuvers into a NativeList<GEManeuverStruct>. Once a maneuver has been executed by the physics core it generates a PhysEvent. PhysicsLoopComplete() examines those maneuvers that have been executed and runs their callbacks (if present). These are then removed from the masterManeuverList and the pending

Note that this means the callbacks will occur when Evolve() loop completes and not when the maneuver occurs. As a result the current GECore state will not correspond to the state at the time of the maneuver. The exact time, position and before/after velocity of the maneuver is contained in the PhysEvent that reports the maneuver was completed.

Parameters
idid of body
mmaneuver to be added
timeOffsetWorldTime(optional) specific offset for maneuver. By default current world time is used.

◆ MassiveIndicesGet()

List< int > GravityEngine2.GECore.MassiveIndicesGet ( )
Returns

◆ MassWorld()

double GravityEngine2.GECore.MassWorld ( int id)

Return mass for a specified object.

Parameters
id
Returns

◆ MuWorld()

double GravityEngine2.GECore.MuWorld ( int id)

Return G * world mass for the body id given.

Parameters
id
Returns
mass

◆ NumBodies()

int GravityEngine2.GECore.NumBodies ( )

Return the total number of bodies in GE (of all types)

Returns

◆ NumRecordedBodies()

int GravityEngine2.GECore.NumRecordedBodies ( )

Number of bodies active in recording function.

Returns

◆ OnRails()

bool GravityEngine2.GECore.OnRails ( )

Determine if all bodies are using deterministic propagators aka all "On Rails". Conversly ensure no bodies are evolving using numerical integration of gravitational forces.

Returns

◆ OrbitPeriodWorldTime()

double GravityEngine2.GECore.OrbitPeriodWorldTime ( )

Provide the time for one period of the reference (scale) orbit in world time units.

Returns

◆ PatchAddToBody() [1/2]

void GravityEngine2.GECore.PatchAddToBody ( int id,
double3 r,
double3 v,
int centerId,
GEPhysicsCore::Propagator prop,
double time_start,
double time_end = -1::0,
double mass = 0::0 )

Add a patch specified via R, V, T at the indicated start time.

This can only be performed on a body for which patch mode is enabled.

Parameters
id
r
v
centerId
prop
time_start
time_end
mass

◆ PatchAddToBody() [2/2]

void GravityEngine2.GECore.PatchAddToBody ( int id,
Orbital::COE oe,
int centerId,
GEPhysicsCore::Propagator prop,
double time_start,
double time_end = -1::0,
double mass = 0::0 )

Add a patch specified via classical orbital elements (COE) at the indicated start time.

This can only be performed on a body for which patch mode is enabled.

Wrapper on the RV AddPatch.

Parameters
id
oe
centerId
prop
time_start
time_end
mass

◆ PhyLoopCompleteCallbackAdd()

void GravityEngine2.GECore.PhyLoopCompleteCallbackAdd ( PhysLoopCompleteCallback cb,
object arg = null )

Add a callback to be invoked when GE physics loop completes running.

This is used when GE is using an IJob on another thread to ensure that changes to state, adding, removing etc are not done while GE is using the physics data.

Physics data from a coherent snapshot can be retreived when the physics loop is running. It cannot be set. This makes code to e.g. compare distance between bodies to run in Update() methods without adding callbacks.

If GE is in immediate mode this code will simply call the cb immediatly. Changes can always be wrapped this way and the control code does not need to care if GE is running physics or not.

Parameters
cb

◆ PhysicsEventCallback()

delegate void GravityEngine2.GECore.PhysicsEventCallback ( GECore ge,
GEPhysicsCore.PhysEvent physEvent )
Parameters
ge
physEvent

◆ PhysicsEventListenerAdd()

void GravityEngine2.GECore.PhysicsEventListenerAdd ( PhysicsEventCallback physEventCB)
Parameters
physEventCB

◆ PhysicsEventListenerRemove()

void GravityEngine2.GECore.PhysicsEventListenerRemove ( PhysicsEventCallback physEventCB)
Parameters
physEventCB

◆ PhysicsJob()

ref GEPhysicsCore.GEPhysicsJob GravityEngine2.GECore.PhysicsJob ( )

Get a reference to the GEPhysicsJob.

Used by GSController for particle update.

User use at your own risk.

Returns

◆ PhysLoopCompleteCallback()

delegate void GravityEngine2.GECore.PhysLoopCompleteCallback ( GECore ge,
object arg = null )

The most flexible way to ask GE to do things is via a callback when the physics loop is complete. This allows the scene to toggle between IMMEDIATE modes and job mode without code changes. When in immediate mode the callbacks are not stored and immediatly run.

This does result in unnecessary indirection when using only IMMEDIATE mode, so it can be skipped if IMMEDIATE mode will not be changed during development.

Parameters
ge
arg

◆ PropagateToTime()

void GravityEngine2.GECore.PropagateToTime ( double tWorld,
int id,
ref GEBodyState state )

Using the propagator for the ID propagate to the requested time and fill in the state struct with the R, V at that time.

If the propagator does not support this, set the time to a negative number.

This only does relative propagation.

Parameters
tworld time to propagate to
idid of body to propagate
statestruct to hold state info (ref)

◆ PropagatorTypeForId()

GEPhysicsCore.Propagator GravityEngine2.GECore.PropagatorTypeForId ( int id)

Return the propagator type for the specified id.

Parameters
id
Returns

◆ RecordedBodies()

NativeArray< int > GravityEngine2.GECore.RecordedBodies ( )
Returns

◆ RecordedOutputGEUnits()

NativeArray< GEBodyState > GravityEngine2.GECore.RecordedOutputGEUnits ( )

Get a reference to the recorded output in GE units.

The output is arranged in "body major" sequence. At timePoint[0] entries 0..numBodies will hold state for each body at time zero. At tp[1] the info is at numBodies..2*numBodies-1 etc.

In the case of trajectory data the array is written as a circular buffer and the last written entry can be determined by TrajectoryStatus()

Returns

◆ RecordedTimesGEUnits()

NativeArray< double > GravityEngine2.GECore.RecordedTimesGEUnits ( )
Returns

◆ RelativeState()

bool GravityEngine2.GECore.RelativeState ( int bodyId,
int centerId,
ref GEBodyState bodyState,
bool geUnits = false )

Provide the state of a body relative to another body (typically the center body which the first body orbits.

Parameters
bodyIdid for which state info is requested
centerIdid for which state is relative to
bodyStatestruct to hold the state information (ref)
geUnitsreturn value in internal GE units (by default will be in world units)
Returns

◆ RepositionAll()

void GravityEngine2.GECore.RepositionAll ( double3 r_offest)

Apply a position and velocity transformation to all states.

Useful to move entire system to e.g. center of mass position and velocity.

Parameters
r_offest

◆ RWorldById()

double3 GravityEngine2.GECore.RWorldById ( int id)

Get the world position of a body of specified id.

Parameters
id
Returns

◆ Schedule()

void GravityEngine2.GECore.Schedule ( double tUntilWorld)

Schedule the job to run until t_until. Do this in a way that the job can be continued with subsequent schedule calls.

Parameters
tUntilWorldend time of gravity evolution

◆ ScheduleRecordOutput()

void GravityEngine2.GECore.ScheduleRecordOutput ( double tUntilWorld,
NativeArray< double > timePoints,
NativeArray< int > bodies )

Run GE evolution in "batch" mode and record the output at specified timePoints for the indicated bodies.

Parameters
tUntilWorld
timePoints
bodies

◆ StateById()

bool GravityEngine2.GECore.StateById ( int id,
ref GEBodyState state,
bool geUnits = false,
bool maintainCoRo = false )

Fill in a state using the id (unique to this GE). The state is at the current world time. Note that the current world time may slightly exceed the time that was requested in the preceeding Evolve() or Schedule() due to the finite step sixe in the numerical integration.

Return value is in default world units unless geUnits are explicitly requested.

Parameters
idid of body
statestruct to hold state info (ref)
geUnitsreturn value in internal GE units (by default will be in world units)
Returns

◆ StateByIdInterpolated()

bool GravityEngine2.GECore.StateByIdInterpolated ( int id,
ref GEBodyState state,
double atTime,
bool geUnits = false )

Determine the state at a time that is slightly earlier than the current world time.

This can be used when a high precision state is required. For example:

  • GECore is asked to evolve to t=10.1
  • due to internal dt step it evolves to t=10.13
  • the state at exactly t=10.1 is of interest In this case asking for the state at time 10.1 will result in an linear interpolation of r and v by the delta.
Parameters
idbody to retrieve state for
statestruct to hold state information (ref)
atTimespecific world time to intepolate state to (less than current world time)
geUnitsreturn value in internal GE units (by default will be in world units)
Returns

◆ StateSetById()

bool GravityEngine2.GECore.StateSetById ( int id,
GEBodyState s,
bool velocityOnly = false,
bool relative = false,
bool geUnits = false )
Parameters
id
s
velocityOnly
relative
geUnits
Returns

◆ TimeGE()

double GravityEngine2.GECore.TimeGE ( )

Time in internal GECore units.

When GEC is configured for ideal scaling (center mass = 1, orbit radius = 1) then the scaling will result in an orbit period of 2 Pi (6.28-ish).

Returns

◆ TimeJulianDays()

double GravityEngine2.GECore.TimeJulianDays ( )

Time expressed as Julian days.

Returns

◆ TimeWorld()

double GravityEngine2.GECore.TimeWorld ( )

Time in world units (defaultUnits when GEC was created).

When in Job mode this function cannot be called when the job is running since time is evolving in the job system. In that case use this function within code added to a physics loop complete callback.

Returns

◆ TimeWorldSet()

bool GravityEngine2.GECore.TimeWorldSet ( double worldTime)

Set the world time.

This is only permitted if all bodies have determinsitic propagators i.e. everything is "on-rails". In such cases the time can be jumped to the future or the past.

Note:

  • any consumed maneuvers will not be undone. This is not a true rewind.
  • if a true rewind is needed for some rails objects, consider enabling patches for those bodies
Parameters
worldTime
Returns

◆ TrajectoryRemove()

void GravityEngine2.GECore.TrajectoryRemove ( int bodyId)

Remove a trajectory from the trajectory recording. This will not require a trajectory reset so it can be done without too much fuss.

Parameters
bodyId

◆ TrajectorySetup()

void GravityEngine2.GECore.TrajectorySetup ( double t_ahead,
int numSteps,
List< int > bodiesToRecord )

Configure this GE to evolve forward by "timeAhead" recording positions at intervals of timeAhead/numSteps.

This is also used when a new body is added: build a new list of bodiesToRecord and run a new setup. [A trajectory reset is needed and more memory needs to be allocated for the circular buffer so there is simple way to 'just' do an add.]

Typical usage: 1) Clone an existing GE (into trajClone, say) and set the clone with ConfigTrajectory 2) Register the trajectory clone with the intial GE so that if there are changes (body add/del etc.) the clone can recompute it's trajectories 3) Have the display/evolve code run the evolution for trajClone the same way it does for GE 4) Display code then retrieves the update position info from trajClone and displays

Parameters
t_aheadtime into future to determine trajectoories
numStepsnumber of intermediate values to asses
bodiesToRecordindices of bodies to gather trajectory information for

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