Gravity Engine 2 5.1
|
Gravity Engine Core Central class for evolution using gravity and propagators. More...
Classes | |
struct | GEConfig |
Public Types | |
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. | |
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. | |
void | ManeuverListAdd (List< GEManeuver > maneuvers, int id, double timeOffsetWorldTime=double.NaN) |
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) |
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) |
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. This callback will be run once when the current physics loop completes (or if in batch mode will be run immediately). | |
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. | |
GEPhysicsCore.Propagator | PropagatorTypeById (int id) |
Get the type of the body. Does not change at run time, so ok to just return it now. | |
GEPhysicsCore.Propagator | PropagatorTypeForId (int id) |
Return the propagator type for the specified id. | |
NativeArray< int > | RecordedBodies () |
NativeArray< GEBodyState > | RecordedOutputGEUnits () |
Get a reference to the recorded output in GE units. | |
NativeArray< double > | RecordedTimesGEUnits () |
ReferenceFrame | RefFrame () |
void | RepositionAll (double3 r_offest) |
Apply a position and velocity transformation to all states. | |
double3 | RWorldById (int id, bool maintainCoRo=false) |
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 | StateByIdAtTime (int id, double tWorld, ref GEBodyState state, bool geUnits=false, bool maintainCoRo=false) |
Determine the relative state of a body at a specific world time. This time may be in the past or future. | |
bool | StateByIdInterpolated (int id, ref GEBodyState state, double atTime, bool geUnits=false, bool maintainCoRo=false) |
Determine the state at a time that is slightly earlier than the current world time. | |
bool | StateByIdRelative (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.) | |
bool | StateSetById (int id, GEBodyState s, bool velocityOnly=false, int relativeCenterId=-1, bool geUnits=false) |
Set the (r,v) state of a body with the indicated id. | |
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 |
Gravity Engine Core Central class for evolution using gravity and propagators.
Handles:
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.
integrator | specify numerical inegration scheme |
defaultUnits | |
lengthScale | length in world units that will be 1 physics unit |
massScale | mass in world units that will be 1 mass unit |
stepsPerOrbit | suggested number of time steps per circular orbit of radius lengthScale |
startTimeJD | start time in Julian date format (only needed when satellite info in TLEs) |
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.
integrator | |
defaultUnits | |
cr3bpSystem | |
stepsPerOrbit | |
startTimeJD |
NotSupportedException |
GravityEngine2.GECore.GECore | ( | GECore | ge, |
bool | copyCallbacks = false ) |
COPY CONSTRUCTOR Create a new GE as a clone of an existing GE.
ge | |
copyCallbacks |
ref GEPhysicsCore.GEBodies GravityEngine2.GECore.BodiesGetAll | ( | ) |
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
rWorld | position in World default units |
vWorld | velocity in World default units |
massWorld | world mass (may be zero) |
isFixed | (optional) body is fixed and will not be moved by GE |
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
coeWorld | orbit elements in default units |
centerId | id of center body of orbit |
prop | propagator |
massWorld | mass of body to add |
isPatched | updates to this body as patches |
time_patch_start | time patches start |
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:
rWorld | relative position in default units |
vWorld | relative velocity in default units |
centerId | body id of center body |
prop | propagator type |
massWorld | mass of object to add |
isPatched | subsequent changes should be added as patches |
time_patch_start | time of first patch |
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
tleData | string representing the two line element info |
centerId | id of center body |
prop | propagator |
isPatched | handle updates to state as patches |
time_patch_start |
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
ephemData | ephemeris data |
cid | center body |
m | mass of body |
isPatched | handle updates as patches |
time_patch_start |
bool GravityEngine2.GECore.BodyRemove | ( | int | id | ) |
Remove a body from GECore.
id |
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).
bodyId | |
centerId | |
usePropCOE | If propagator has internal COE, use that instead of recomputing from R, V |
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.
id | body id |
radius | spherical size of this body in default World units |
bounceF | bounce factor for elastic collisions |
collisionType | interaction type (absorb/bounce) |
mass | inertial mass |
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.
double GravityEngine2.GECore.Dt | ( | ) |
Numerical integration timestep value.
void GravityEngine2.GECore.DtSet | ( | double | dt | ) |
Configure the internal timestep used in numerical integration.
dt |
string GravityEngine2.GECore.DumpAll | ( | string | info = "", |
bool | worldScale = false ) |
info | |
worldScale |
void GravityEngine2.GECore.EvolveNow | ( | double | tUntilWorld | ) |
tUntilWorld |
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 +
t_until | |
timePoints | |
bodies |
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
[*] technically an unsafe function pointer can be used, but the Asset Store does not permit assets to declare unsafe code.
bodyId | identity of body to compute external acceleration |
eaType | type of force (self/on-other) |
accelType | enumerated type to slect force |
accelData | parameters for force calculation |
double3[] GravityEngine2.GECore.ExternalAccelerationData | ( | int | extAccelId | ) |
Return a copy of the external acceleration params.
extAccelId | the id of the external acceleration (NOT bodyId!) |
void GravityEngine2.GECore.ExternalAccelerationDataUpdate | ( | int | extAccelId, |
double3[] | data ) |
Update the external acceleration parameters for a specific external acceleration.
extAccelId | |
data |
void GravityEngine2.GECore.ExternalAccelerationRemove | ( | int | extAccelId | ) |
Remove the external acceleration.
extAccelId |
GBUnits.GEScaler GravityEngine2.GECore.GEScaler | ( | ) |
Get the GEScalar. Used when code needs to determine conversions from physics space (GEC internal) to world units.
double GravityEngine2.GECore.GetParm | ( | int | index | ) |
Get information from the GE physics config.
index |
bool GravityEngine2.GECore.IsCompleted | ( | ) |
Poll to see if the jobs that were scheduled are complete.
bool GravityEngine2.GECore.IsRunning | ( | ) |
Determine if GECore is currently running a physical loop.
void GravityEngine2.GECore.ListenerAdd | ( | GEListenerIF | geListener | ) |
Add a listener.
Currently used to get a callback when a body is removed due to a collision.
geListener |
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.
id | id of body |
m | maneuver to be added |
timeOffsetWorldTime | (optional) specific offset for maneuver. By default current world time is used. |
List< int > GravityEngine2.GECore.MassiveIndicesGet | ( | ) |
double GravityEngine2.GECore.MassWorld | ( | int | id | ) |
Return mass for a specified object.
id |
double GravityEngine2.GECore.MuWorld | ( | int | id | ) |
Return G * world mass for the body id given.
id |
int GravityEngine2.GECore.NumBodies | ( | ) |
Return the total number of bodies in GE (of all types)
int GravityEngine2.GECore.NumRecordedBodies | ( | ) |
Number of bodies active in recording function.
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.
double GravityEngine2.GECore.OrbitPeriodWorldTime | ( | ) |
Provide the time for one period of the reference (scale) orbit in world time units.
void GravityEngine2.GECore.PatchAddToBody | ( | int | id, |
double3 | r, | ||
double3 | v, | ||
int | centerId, | ||
GEPhysicsCore::Propagator | prop, | ||
double | time_start, | ||
double | time_end = -1::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.
id | |
r | |
v | |
centerId | |
prop | |
time_start | |
time_end | |
mass |
void GravityEngine2.GECore.PatchAddToBody | ( | int | id, |
Orbital::COE | oe, | ||
int | centerId, | ||
GEPhysicsCore::Propagator | prop, | ||
double | time_start, | ||
double | time_end = -1::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.
id | |
oe | |
centerId | |
prop | |
time_start | |
time_end | |
mass |
void GravityEngine2.GECore.PhyLoopCompleteCallbackAdd | ( | PhysLoopCompleteCallback | cb, |
object | arg = null ) |
Add a callback to be invoked when GE physics loop completes running. This callback will be run once when the current physics loop completes (or if in batch mode will be run immediately).
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.
cb |
delegate void GravityEngine2.GECore.PhysicsEventCallback | ( | GECore | ge, |
GEPhysicsCore.PhysEvent | physEvent ) |
ge | |
physEvent |
void GravityEngine2.GECore.PhysicsEventListenerAdd | ( | PhysicsEventCallback | physEventCB | ) |
physEventCB |
void GravityEngine2.GECore.PhysicsEventListenerRemove | ( | PhysicsEventCallback | physEventCB | ) |
physEventCB |
ref GEPhysicsCore.GEPhysicsJob GravityEngine2.GECore.PhysicsJob | ( | ) |
Get a reference to the GEPhysicsJob.
Used by GSController for particle update.
User use at your own risk.
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.
ge | |
arg |
GEPhysicsCore.Propagator GravityEngine2.GECore.PropagatorTypeById | ( | int | id | ) |
Get the type of the body. Does not change at run time, so ok to just return it now.
id |
GEPhysicsCore.Propagator GravityEngine2.GECore.PropagatorTypeForId | ( | int | id | ) |
Return the propagator type for the specified id.
id |
NativeArray< int > GravityEngine2.GECore.RecordedBodies | ( | ) |
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()
NativeArray< double > GravityEngine2.GECore.RecordedTimesGEUnits | ( | ) |
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.
r_offest |
double3 GravityEngine2.GECore.RWorldById | ( | int | id, |
bool | maintainCoRo = false ) |
Get the world position of a body of specified id.
id | |
maintainCoRo | maintain the co-rotating frame (default false) |
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.
tUntilWorld | end time of gravity evolution |
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.
tUntilWorld | |
timePoints | |
bodies |
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.
id | id of body |
state | struct to hold state info (ref) |
geUnits | return value in internal GE units (by default will be in world units) |
maintainCoRo | maintain the co-rotating frame (default false) |
bool GravityEngine2.GECore.StateByIdAtTime | ( | int | id, |
double | tWorld, | ||
ref GEBodyState | state, | ||
bool | geUnits = false, | ||
bool | maintainCoRo = false ) |
Determine the relative state of a body at a specific world time. This time may be in the past or future.
If the propagator does not support this, the state will be set to NaN.
This only does relative propagation. TODO: extend to absolute by propagating the center body etc.
t | world time to propagate to |
id | id of body to propagate |
state | struct to hold state info (ref) |
bool GravityEngine2.GECore.StateByIdInterpolated | ( | int | id, |
ref GEBodyState | state, | ||
double | atTime, | ||
bool | geUnits = false, | ||
bool | maintainCoRo = 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:
id | body to retrieve state for |
state | struct to hold state information (ref) |
atTime | specific world time to intepolate state to (less than current world time) |
geUnits | return value in internal GE units (by default will be in world units) |
maintainCoRo | maintain the co-rotating frame (default false) |
bool GravityEngine2.GECore.StateByIdRelative | ( | 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.)
bodyId | id for which state info is requested |
centerId | id for which state is relative to |
bodyState | struct to hold the state information (ref) |
geUnits | return value in internal GE units (by default will be in world units) |
bool GravityEngine2.GECore.StateSetById | ( | int | id, |
GEBodyState | s, | ||
bool | velocityOnly = false, | ||
int | relativeCenterId = -1, | ||
bool | geUnits = false ) |
Set the (r,v) state of a body with the indicated id.
By default the state is set in absoluteworld units. If geUnits is true the state is set in internal GE units.
In some cases it is useful to set a state by specifying the (r,v) relative to another body. This is done by setting relativeCenterId to the id of the body to which the state is relative.
This can be used for GRAVITY and KEPLER propagators.
If the relative centerId is provided, the state is set relative to the center body.
id | |
s | |
velocityOnly | |
relativeCenterId | |
geUnits |
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).
double GravityEngine2.GECore.TimeJulianDays | ( | ) |
Time expressed as Julian days.
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.
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:
worldTime |
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.
bodyId |
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
t_ahead | time into future to determine trajectoories |
numSteps | number of intermediate values to asses |
bodiesToRecord | indices of bodies to gather trajectory information for |