Gravity Engine  1.5
Unity Asset for Gravity
INBodyIntegrator Interface Reference

Common interface for numerical NBody integration. Used by the GravityEngine. More...

Inheritance diagram for INBodyIntegrator:
AZTripleIntegrator HermiteIntegrator LeapFrogIntegrator

Public Member Functions

void Setup (int maxBodies, double timeStep)
 Setup the specified maxBodies and timeStep. Must be called prior to PreEvolve/Evolve More...
 
INBodyIntegrator DeepClone ()
 Clone this instance, replicating internal arrays. Copy across any internal state required for continued evolution. More...
 
void AddNBody (int bodyNum, NBody nbody, Vector3 position, Vector3 velocity)
 Adds the N body. Implementation may support the case where the initial number of bodies in Setup() is exceeded, creating space, or may ignore additions that exceed this limit (e.g. AZTTriple). More...
 
void RemoveBodyAtIndex (int atIndex)
 Removes NBody at index i. More...
 
void GrowArrays (int growBy)
 Grows the arrays. Called by GravityEngine when it changes internal data sizes. More...
 
Vector3 GetVelocityForIndex (int i)
 
void GetVelocityDoubleForIndex (int i, ref double[] v)
 
void SetVelocityForIndex (int i, Vector3 vel)
 
Vector3 GetAccelerationForIndex (int i)
 
void PreEvolve (GravityState gravityState, ref byte[] info)
 Call ONCE after all game objects have been added to allow integrator to pre-calc starting quantities required for integration More...
 
double Evolve (double time, GravityState gravityState, ref byte[] info)
 Evolve the specified time, m, r and info. More...
 
float GetEnergy (GravityState gravityState)
 Gets the energy of the system. More...
 
float GetInitialEnergy (GravityState gravityState)
 Gets the initial energy. More...
 

Detailed Description

Common interface for numerical NBody integration. Used by the GravityEngine.

Index Tracking:

  • GravityEngine tracks adds/removes and maintains an index list. The positions and velocities are in arrays in gravity engine (since they are common to all bodies and needed for game object position updates)

This interface is not normally called from developer scripts.

Member Function Documentation

void INBodyIntegrator.AddNBody ( int  bodyNum,
NBody  nbody,
Vector3  position,
Vector3  velocity 
)

Adds the N body. Implementation may support the case where the initial number of bodies in Setup() is exceeded, creating space, or may ignore additions that exceed this limit (e.g. AZTTriple).

Parameters
nbodyNBody component
positionPhysics position
velocityPhysics velocity

Implemented in AZTripleIntegrator, HermiteIntegrator, and LeapFrogIntegrator.

INBodyIntegrator INBodyIntegrator.DeepClone ( )

Clone this instance, replicating internal arrays. Copy across any internal state required for continued evolution.

Implemented in AZTripleIntegrator, HermiteIntegrator, and LeapFrogIntegrator.

double INBodyIntegrator.Evolve ( double  time,
GravityState  gravityState,
ref byte[]  info 
)

Evolve the specified time, m, r and info.

Integrators will evolve for at least as long as the specified time, but can overshoot. The GravityEngine will correct on the next cycle.

Parameters
timeTime.
mM.
rThe red component.
infoInfo.

Implemented in HermiteIntegrator, AZTripleIntegrator, and LeapFrogIntegrator.

float INBodyIntegrator.GetEnergy ( GravityState  gravityState)

Gets the energy of the system.

Returns
The energy.
Parameters
massMass.
posPosition.

Implemented in AZTripleIntegrator, HermiteIntegrator, and LeapFrogIntegrator.

float INBodyIntegrator.GetInitialEnergy ( GravityState  gravityState)

Gets the initial energy.

Returns
The initial energy.
Parameters
massMass.
posPosition.

Implemented in AZTripleIntegrator, HermiteIntegrator, and LeapFrogIntegrator.

void INBodyIntegrator.GrowArrays ( int  growBy)

Grows the arrays. Called by GravityEngine when it changes internal data sizes.

Parameters
growByGrow by.

Implemented in AZTripleIntegrator, HermiteIntegrator, and LeapFrogIntegrator.

void INBodyIntegrator.PreEvolve ( GravityState  gravityState,
ref byte[]  info 
)

Call ONCE after all game objects have been added to allow integrator to pre-calc starting quantities required for integration

To avoid copies of mass and position arrays in integrators provide a reference to these for Evolve and PreEvolve

Some implementations (e.g. AZTriple) may make their own copies and then copy the result back into these arrays ///

Parameters
mM.
rThe red component.
infoInfo.

Implemented in HermiteIntegrator, AZTripleIntegrator, and LeapFrogIntegrator.

void INBodyIntegrator.RemoveBodyAtIndex ( int  atIndex)

Removes NBody at index i.

Parameters
atIndexAt index.

Implemented in AZTripleIntegrator, HermiteIntegrator, and LeapFrogIntegrator.

void INBodyIntegrator.Setup ( int  maxBodies,
double  timeStep 
)

Setup the specified maxBodies and timeStep. Must be called prior to PreEvolve/Evolve

Parameters
maxBodiesMax bodies.
timeStepTime step.

Implemented in HermiteIntegrator, AZTripleIntegrator, and LeapFrogIntegrator.


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