Gravity Engine 12.0
Unity Asset for Gravity
|
DEPREACTED: Please use OrbitUniversal Class used to handle the hyperbolic orbital parameters and draw the orbit path in the editor using Gizmos. More...
Public Types | |
enum | EvolveType { GRAVITY_ENGINE , KEPLERS_EQN } |
Public Member Functions | |
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). | |
void | Init () |
Init the hyperbola, verify a center body is present and determine orientation. | |
void | InitFromOrbitData (OrbitData od) |
void | SetCenterBody (GameObject centerBody) |
Sets the center body and initializes the hyperbola configuration. | |
float | GetSemiParam () |
Get the semi-parameter p. | |
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 | InitNBody (float physicalScale, float massScale) |
Inits the N body position and velocity based on the hyperbola parameters and the position and velocity of the parent. | |
Vector3 | PositionForThetaLeftBranch (float theta, Vector3 centerPos) |
Given an angle (radians) determine the position on the left branch of the hyperbola. | |
Vector3[] | OrbitPositions (int numPoints, Vector3 centerPos, bool doSceneMapping) |
Calculate an array of orbit positions. Used by the OrbitPredictor, OrbitRenderer and Editor Gimzo to illustrate the hyperbola. | |
float | ThetaForPosition (Vector3 position, Vector3 cPos) |
Determine the angle for a position on the hyperbola given the position. | |
Vector3 | MirrorPhysPosition (Vector3 pos, Vector3 cPos) |
Given a position for an object in a hyperbolic orbit, determine the mirror position on the other side of the central body. | |
Vector3 | MirrorPhysVelocity (NBody body) |
Vector3[] | OrbitSegmentSymmetricPositions (int numPoints, Vector3 centerPos, Vector3 startPos) |
Determine points from body through closest approach the same distance on the other side. | |
void | Log (string prefix) |
void | ApplyScale (float scale) |
Apply scale to the orbit. This is used by the inspector scripts during scene setup. Do not use at run-time. | |
void | ApplyXZChange () |
GameObject | GetCenterObject () |
Return the center object around which this ellipse is defined. | |
void | PreEvolve (float physicalScale, float massScale) |
Called for each NBody object prior to evolution beginning. Allows a chance to setup internal state. | |
float | GetTimeToPeriapse () |
void | Evolve (double physicsTime, GravityState gs, ref double[] r_new, ref double[] v_new, bool doCallbacks=true) |
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. | |
Vector3 | GetVelocity () |
Vector3 | GetPosition () |
Vector3d | GetPositionDouble () |
void | GEUpdate (GravityEngine ge) |
Perform and update of the world game object position and velocity based on the internal state. | |
void | Move (Vector3 moveBy) |
Handle dynamic origin shift. | |
NBody | GetCenterNBody () |
Return the center NBody for the fixed orbit. | |
Vector3 | ApplyImpulse (Vector3 impulse) |
ApplyImpulse in Kepler mode. (Currently only OrbitUniversal does this) | |
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. | |
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 () |
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. | |
Public Attributes | |
EvolveType | evolveMode = EvolveType.GRAVITY_ENGINE |
Use GRAVITY_ENGINE to evolve or move in a fixed KEPLER orbit. | |
GameObject | centerObject |
object to orbit around (if null, will take parent game object) | |
float | ecc = 2.0f |
eccentricity (0..1, 0=circle, 1=linear) | |
float | perihelion = 10f |
Hyperbola parameters: The definition is typically in terms of semi-parameter p (semi-latus recturm) but using the perispase (closest approach) is more user-friendly. | |
float | branchDisplayFactor = 0.5f |
fraction of the branch of the hyperbola to display in OrbitPositions | |
float | omega_uc |
"longitude of ascending node" - angle from x-axis to line from focus to pericenter | |
float | omega_lc |
"argument of perienter" - angle from ascending node to pericenter | |
float | inclination |
inclination (degrees!) | |
float | r_initial = 10f |
initial distance from focus | |
bool | r_initial_outbound = false |
initial distance on outbound leg | |
bool | r_start_flip = false |
Protected Member Functions | |
void | CalcOrbitParams () |
void | CalculateRotation () |
Protected Attributes | |
Quaternion | hyper_orientation |
Vector3 | xunit = Vector3.right |
Vector3 | yunit = Vector3.up |
Vector3 | zunit = Vector3.forward |
NBody | centerNbody |
DEPREACTED: Please use OrbitUniversal Class used to handle the hyperbolic orbital parameters and draw the orbit path in the editor using Gizmos.
How to specify an hyperbola in 3D:
p - pericenter - distance from focus of hyperbola to point of closest approach to that focus
shape: controlled by ecc (eccentricity) 0 for a circle, 0.99 for a very long thin ellipse
orientation: The standard orbit parameters are used. You can develop some intuition for these by chaging them in the Editor and observing the change in the orbit.
Orientation is defined with respect to the positive X axis. omega (lower case) - is a rotation in the plane of the orbit Inclination - is the tilt of the closest approach vector to the XY plance Omega (capital Omega) - is the rotation around Z after preceeding rotations
Vector3 OrbitHyper.ApplyImpulse | ( | Vector3 | impulse | ) |
ApplyImpulse in Kepler mode. (Currently only OrbitUniversal does this)
Implements IFixedOrbit.
void OrbitHyper.ApplyScale | ( | float | scale | ) |
Apply scale to the orbit. This is used by the inspector scripts during scene setup. Do not use at run-time.
scale | Scale. |
Implements IOrbitScalable.
void OrbitHyper.ApplyXZChange | ( | ) |
Implements IOrbitScalable.
string OrbitHyper.DumpInfo | ( | ) |
void OrbitHyper.Evolve | ( | double | physicsTime, |
GravityState | gravityState, | ||
ref double[] | r, | ||
ref double[] | v, | ||
bool | isQuery = true |
||
) |
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 OrbitHyper.GetCenterNBody | ( | ) |
GameObject OrbitHyper.GetCenterObject | ( | ) |
Return the center object around which this ellipse is defined.
float OrbitHyper.GetSemiParam | ( | ) |
Get the semi-parameter p.
void OrbitHyper.GEUpdate | ( | GravityEngine | ge | ) |
Perform and update of the world game object position and velocity based on the internal state.
Implements IFixedOrbit.
void OrbitHyper.InitNBody | ( | float | physicalScale, |
float | massScale | ||
) |
Inits the N body position and velocity based on the hyperbola parameters and the position and velocity of the parent.
physicalScale | Physical scale. |
Implements INbodyInit.
bool OrbitHyper.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)
true
if this instance is fixed; otherwise, false
.Implements IFixedOrbit.
Vector3 OrbitHyper.MirrorPhysPosition | ( | Vector3 | pos, |
Vector3 | cPos | ||
) |
Given a position for an object in a hyperbolic orbit, determine the mirror position on the other side of the central body.
Commonly used for patched conic hyperbolic segments around a moon/planet at the SOI.
pos | |
cPos |
void OrbitHyper.Move | ( | Vector3 | position | ) |
Vector3[] OrbitHyper.OrbitPositions | ( | int | numPoints, |
Vector3 | centerPos, | ||
bool | doSceneMapping | ||
) |
Calculate an array of orbit positions. Used by the OrbitPredictor, OrbitRenderer and Editor Gimzo to illustrate the hyperbola.
numPoints | Number points. |
Implements IOrbitPositions.
Vector3[] OrbitHyper.OrbitSegmentSymmetricPositions | ( | int | numPoints, |
Vector3 | centerPos, | ||
Vector3 | startPos | ||
) |
Determine points from body through closest approach the same distance on the other side.
numPoints | |
centerPos | |
startPos |
Vector3 OrbitHyper.PositionForThetaLeftBranch | ( | float | theta, |
Vector3 | centerPos | ||
) |
Given an angle (radians) determine the position on the left branch of the hyperbola.
theta | |
centerPos |
void OrbitHyper.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.
void OrbitHyper.SetCenterBody | ( | GameObject | centerBody | ) |
Sets the center body and initializes the hyperbola configuration.
centerBody | Center body. |
void OrbitHyper.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).
nbody |
Implements IFixedOrbit.
float OrbitHyper.ThetaForPosition | ( | Vector3 | position, |
Vector3 | cPos | ||
) |
Determine the angle for a position on the hyperbola given the position.
position |
void OrbitHyper.UpdatePositionAndVelocity | ( | Vector3 | pos, |
Vector3 | vel | ||
) |
Update the position and velocity of the object in the orbit.
Currently only implemented in OrbitUniversal for changes in the center body due to patched conic transitions.
pos | |
vel |
Implements IFixedOrbit.
float OrbitHyper.perihelion = 10f |
Hyperbola parameters: The definition is typically in terms of semi-parameter p (semi-latus recturm) but using the perispase (closest approach) is more user-friendly.
a,p are calculated from the periapse and used for orbital calculations internally. point of closest approach in selected units (should really be called periapse, but for backwards compat. leave it)