Gravity Engine 12.0
Unity Asset for Gravity
|
Kepler elements maintains a time ordered list of OrbitUniversal segments. This allows a seqence of orbits around different bodies to be specified. For example, a free return trajectory around a moon would have: ellipse around Earth, hyperbola around moon, ellipse around Earth as three segements. By putting everything "on-rails" the scene can jump in time to any value requested without running NBody calculations for all the intermediate positions. More...
Classes | |
class | KeplerElement |
Public Member Functions | |
delegate void | ElementStarted (OrbitUniversal orbitU) |
Optional callback to indicate when a specific element in the sequence starts. | |
delegate void | ReactivateCallback (NBody nbody) |
delegate void | InactivateCallback (NBody nbody) |
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. | |
OrbitUniversal | AppendElementRVT (Vector3d r0, Vector3d v0, double time, bool relativePos, NBody body, NBody centerBody, ElementStarted callback, Maneuver m=null) |
Add an element to the sequence using r0/v0/t0 initial conditions. | |
OrbitUniversal | NewOrbitSegment () |
void | AdvanceToNextSegment () |
Force KS to go to the next element. | |
void | AppendElementExistingOrbitU (OrbitUniversal orbitU, ElementStarted callback) |
Add an element using an existing OrbitUniversal instance. | |
void | AppendReturnToGE (double time, NBody body) |
void | AppendInactive (double time, InactivateCallback inactivateCallback, ReactivateCallback reactivateCallback) |
void | Evolve (double physicsTime, GravityState gs, 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. | |
OrbitUniversal | GetCurrentOrbit () |
Get the current OrbitUniversal for the orbit. | |
OrbitUniversal | GetOrbitAtIndex (int index) |
Get orbit at the specified index. If -1 use the last entry. | |
int | GetCurrentOrbitIndex () |
Return the index of the current orbit sequence. (Used in the editor script for in-scene display) | |
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 | PreEvolve (float physicalScale, float massScale) |
Called for each NBody object prior to evolution beginning. Allows a chance to setup internal state. | |
void | SetNBody (NBody nbody) |
Not valid for a Kepler Sequence. | |
void | SetTimeoffset (double timeOffset) |
NBody | GetCenterNBody () |
Return the center NBody for the fixed orbit. | |
Vector3 | ApplyImpulse (Vector3 impulse) |
Apply the impulse to the current OrbitUniversal element. | |
bool | IsOnRails () |
Usual case is that a KeplerSequence is on rails but can be a misconfiguration where the base OrbitUniversal is set to GE mode. In this case assume the OrbitUnversal config is intentional, warn about the misconfig and continue. | |
void | UpdatePositionAndVelocity (Vector3 pos, Vector3 vel) |
Set the position and velocity at the current time. | |
void | AddManeuver (Maneuver m) |
void | AddManeuvers (List< Maneuver > maneuverList) |
Add orbit segments for each of the maneuvers. The maneuvers must have been created by transfer code that populated the fields: relativeTo, relativePos, relativeVel and time fields. | |
bool | RemoveManeuvers (List< Maneuver > maneuverList) |
Remove maneuvers from the Kepler sequence IF they have not started yet. | |
void | RemoveFutureSegments () |
Remove all segments that occur after the current time. | |
void | RemoveSegmentsAfterTime (double time) |
Remove all segments after the specified time. | |
void | Reset () |
Remove all previous and current segments. Used when a body is put back on rails after a period of NBody evolution. The on-rails code will explicitly add an orbitU. | |
void | CopyFrom (KeplerSequence copyFrom, bool retainActivateCallbacks=false, bool retainManeuverCallbacks=false) |
Make a copy of the KeplerSequence copyFrom. | |
string | DumpInfo () |
Create a string with info for display in GEConsole. | |
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. | |
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. | |
Kepler elements maintains a time ordered list of OrbitUniversal segments. This allows a seqence of orbits around different bodies to be specified. For example, a free return trajectory around a moon would have: ellipse around Earth, hyperbola around moon, ellipse around Earth as three segements. By putting everything "on-rails" the scene can jump in time to any value requested without running NBody calculations for all the intermediate positions.
On Init the KeplerSequence will automatically find and add the existing OrbitUniversal at the start of the list.
Note that this is NOT real physics since it is a series of two body evolutions and it is not what would really happen. It may be a good enough model for a game, depending on the importance of accuracy vs utility of jumping in time and getting results that do not vary based on numerical accuracy chosen for the GE.
The individual orbital elements are created as components and attached to a synthesized child object (this ensures the KeplerSequence can be unambigously attached to an NBody. This requires that the active body and center body for the sequence elements be set explicitly (they cannot be inferred).
void KeplerSequence.AddManeuvers | ( | List< Maneuver > | maneuverList | ) |
Add orbit segments for each of the maneuvers. The maneuvers must have been created by transfer code that populated the fields: relativeTo, relativePos, relativeVel and time fields.
list |
void KeplerSequence.AdvanceToNextSegment | ( | ) |
Force KS to go to the next element.
This is hacky and is used in the case where a KS SetVelocityDouble is used by the auto-tester in the same flow where an orbit check will be done before a newly appended element at the current time becomes active.
void KeplerSequence.AppendElementExistingOrbitU | ( | OrbitUniversal | orbitU, |
ElementStarted | callback | ||
) |
Add an element using an existing OrbitUniversal instance.
Orbit elements must be added in increasing time order.
orbitU | |
callback | (Optional) Method to call when sequence starts |
OrbitUniversal KeplerSequence.AppendElementRVT | ( | Vector3d | r0, |
Vector3d | v0, | ||
double | time, | ||
bool | relativePos, | ||
NBody | body, | ||
NBody | centerBody, | ||
ElementStarted | callback, | ||
Maneuver | m = null |
||
) |
Add an element to the sequence using r0/v0/t0 initial conditions.
Position and velocity are with respect to the center body (NOT world/physics space!).
Orbit segements must be added in increasing time order.
r0 | |
v0 | |
time | |
relativePos | |
body | |
centerBody | |
callback | (Optional) Method to call when sequence starts |
Vector3 KeplerSequence.ApplyImpulse | ( | Vector3 | impulse | ) |
Apply the impulse to the current OrbitUniversal element.
This will break time-reversal because this change in impulse is not recorded.
impulse |
Implements IFixedOrbit.
void KeplerSequence.CopyFrom | ( | KeplerSequence | copyFrom, |
bool | retainActivateCallbacks = false , |
||
bool | retainManeuverCallbacks = false |
||
) |
Make a copy of the KeplerSequence copyFrom.
copyFrom |
string KeplerSequence.DumpInfo | ( | ) |
void KeplerSequence.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.
physicsTime | Current Physics time. |
physicalScale | Physical scale. |
r | Position in physics space (x, y, z). OUTPUT by the method |
v | Velocity in physics space (x, y, z). OUTPUT by the method |
isQuery | Request is a query and should not change state or do callbacks |
Implements IFixedOrbit.
NBody KeplerSequence.GetCenterNBody | ( | ) |
OrbitUniversal KeplerSequence.GetCurrentOrbit | ( | ) |
Get the current OrbitUniversal for the orbit.
int KeplerSequence.GetCurrentOrbitIndex | ( | ) |
Return the index of the current orbit sequence. (Used in the editor script for in-scene display)
OrbitUniversal KeplerSequence.GetOrbitAtIndex | ( | int | index | ) |
Get orbit at the specified index. If -1 use the last entry.
index |
void KeplerSequence.GEUpdate | ( | GravityEngine | ge | ) |
Perform and update of the world game object position and velocity based on the internal state.
Implements IFixedOrbit.
void KeplerSequence.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.
physicalScale | Physical scale. |
Implements INbodyInit.
bool KeplerSequence.IsOnRails | ( | ) |
Usual case is that a KeplerSequence is on rails but can be a misconfiguration where the base OrbitUniversal is set to GE mode. In this case assume the OrbitUnversal config is intentional, warn about the misconfig and continue.
Implements IFixedOrbit.
void KeplerSequence.Move | ( | Vector3 | position | ) |
void KeplerSequence.PreEvolve | ( | float | physicalScale, |
float | massScale | ||
) |
Called for each NBody object prior to evolution beginning. Allows a chance to setup internal state.
physicalScale | Physical scale. |
massScale | Mass scale. |
Implements IFixedOrbit.
bool KeplerSequence.RemoveManeuvers | ( | List< Maneuver > | maneuverList | ) |
Remove maneuvers from the Kepler sequence IF they have not started yet.
If they have started or are in the past, leave in place and return an error.
maneuverList |
void KeplerSequence.RemoveSegmentsAfterTime | ( | double | time | ) |
Remove all segments after the specified time.
time |
void KeplerSequence.SetNBody | ( | NBody | nbody | ) |
void KeplerSequence.UpdatePositionAndVelocity | ( | Vector3 | pos, |
Vector3 | vel | ||
) |
Set the position and velocity at the current time.
This will break time reversal since the change is not recorded.
pos | |
vel |
Implements IFixedOrbit.