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

DEPREACTED: Please use OrbitUniversal Class used to handle the hyperbolic orbital parameters and draw the orbit path in the editor using Gizmos. More...

Inheritance diagram for OrbitHyper:
INbodyInit IOrbitPositions IOrbitScalable IFixedOrbit

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
 

Detailed Description

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

Member Function Documentation

◆ ApplyImpulse()

Vector3 OrbitHyper.ApplyImpulse ( Vector3  impulse)

ApplyImpulse in Kepler mode. (Currently only OrbitUniversal does this)

Returns

Implements IFixedOrbit.

◆ ApplyScale()

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.

Parameters
scaleScale.

Implements IOrbitScalable.

◆ ApplyXZChange()

void OrbitHyper.ApplyXZChange ( )

Implements IOrbitScalable.

◆ DumpInfo()

string OrbitHyper.DumpInfo ( )

Create a string with info for display in GEConsole.

Returns

Implements IFixedOrbit.

◆ Evolve()

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.

Parameters
physicsTimeCurrent Physics time.
physicalScalePhysical scale.
rPosition in physics space (x, y, z). OUTPUT by the method
vVelocity in physics space (x, y, z). OUTPUT by the method
isQueryRequest is a query and should not change state or do callbacks

Implements IFixedOrbit.

◆ GetCenterNBody()

NBody OrbitHyper.GetCenterNBody ( )

Return the center NBody for the fixed orbit.

Returns

Implements IFixedOrbit.

◆ GetCenterObject()

GameObject OrbitHyper.GetCenterObject ( )

Return the center object around which this ellipse is defined.

Returns
The center object.

◆ GetSemiParam()

float OrbitHyper.GetSemiParam ( )

Get the semi-parameter p.

Returns

◆ GEUpdate()

void OrbitHyper.GEUpdate ( GravityEngine  ge)

Perform and update of the world game object position and velocity based on the internal state.

Implements IFixedOrbit.

◆ InitNBody()

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.

Parameters
physicalScalePhysical scale.

Implements INbodyInit.

◆ IsOnRails()

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)

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

Implements IFixedOrbit.

◆ MirrorPhysPosition()

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.

Parameters
pos
cPos
Returns

◆ Move()

void OrbitHyper.Move ( Vector3  position)

Handle dynamic origin shift.

Parameters
position

Implements IFixedOrbit.

◆ OrbitPositions()

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.

Returns
The positions.
Parameters
numPointsNumber points.

Implements IOrbitPositions.

◆ OrbitSegmentSymmetricPositions()

Vector3[] OrbitHyper.OrbitSegmentSymmetricPositions ( int  numPoints,
Vector3  centerPos,
Vector3  startPos 
)

Determine points from body through closest approach the same distance on the other side.

Parameters
numPoints
centerPos
startPos
Returns

◆ PositionForThetaLeftBranch()

Vector3 OrbitHyper.PositionForThetaLeftBranch ( float  theta,
Vector3  centerPos 
)

Given an angle (radians) determine the position on the left branch of the hyperbola.

Parameters
theta
centerPos
Returns

◆ PreEvolve()

void OrbitHyper.PreEvolve ( float  physicalScale,
float  massScale 
)

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

Parameters
physicalScalePhysical scale.
massScaleMass scale.

Implements IFixedOrbit.

◆ SetCenterBody()

void OrbitHyper.SetCenterBody ( GameObject  centerBody)

Sets the center body and initializes the hyperbola configuration.

Parameters
centerBodyCenter body.

◆ SetNBody()

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).

Parameters
nbody

Implements IFixedOrbit.

◆ ThetaForPosition()

float OrbitHyper.ThetaForPosition ( Vector3  position,
Vector3  cPos 
)

Determine the angle for a position on the hyperbola given the position.

Parameters
position
Returns

◆ UpdatePositionAndVelocity()

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.

Parameters
pos
vel

Implements IFixedOrbit.

Member Data Documentation

◆ perihelion

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)


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