Gravity Engine  1.5
Unity Asset for Gravity
GravityScaler Class Reference
Inheritance diagram for GravityScaler:

Public Types

enum  Units { DIMENSIONLESS, SI, ORBITAL, SOLAR }
 

Static Public Member Functions

static void UpdateTimeScale (Units units, float timeScale, float lengthScale)
 
static float GetVelocityScale ()
 
static void ScaleScene (Units units, float timeScale, float lengthScale)
 Changes the length scale of all NBody objects in the scene due to a change in the inspector. Find all NBody containing objects. More...
 
static void ScaleNBody (NBody nbody, Units units, float timeScale, float lengthScale)
 Scales the N body using the provided units and length scale. More...
 
static string LengthUnits (Units units)
 Return the string indicating the length units in use by the gravity engine. More...
 
static string VelocityUnits (Units units)
 Return the string indicating the velocity units in use by the gravity engine. More...
 
static string MassUnits (Units units)
 Return the string indicating the mass units in use by the gravity engine. More...
 

Public Attributes

const float G = 6.67408E-11f
 Units. Gravity N-Body simulations use units in which G=1 (G, the gravitational constant). More...
 
Units units
 

Member Function Documentation

static string GravityScaler.LengthUnits ( Units  units)
static

Return the string indicating the length units in use by the gravity engine.

Returns
The units.
static string GravityScaler.MassUnits ( Units  units)
static

Return the string indicating the mass units in use by the gravity engine.

Returns
The units.
static void GravityScaler.ScaleNBody ( NBody  nbody,
Units  units,
float  timeScale,
float  lengthScale 
)
static

Scales the N body using the provided units and length scale.

Parameters
nbodyNbody.
unitsUnits.
timeScaleTime scale.
lengthScaleLength scale.
static void GravityScaler.ScaleScene ( Units  units,
float  timeScale,
float  lengthScale 
)
static

Changes the length scale of all NBody objects in the scene due to a change in the inspector. Find all NBody containing objects.

  • independent objects are rescaled
  • orbit based objects have their primary dimension adjusted (e.g. for ellipse, a) (these objects are scalable and are asked to rescale themselves)

Not intended for run-time use.

static string GravityScaler.VelocityUnits ( Units  units)
static

Return the string indicating the velocity units in use by the gravity engine.

Returns
The units.

Member Data Documentation

const float GravityScaler.G = 6.67408E-11f

Units. Gravity N-Body simulations use units in which G=1 (G, the gravitational constant).

From unit analysis of F = m_1 a = (G m_1 m_2)/r^2 we get: T = (L^3/G M)^(1/2) with T = time, L = length, M = Mass, G=Newton's constant = 6.67E-11.

SI (m,kg) => T=1.224E5 sec Solar (AU, 1E24 kg) => T = 7.083E9 sec.

To control game time, mass is rescaled in the physics engine to acheive the desired result. Initial velocities are also adjusted to appropriate scale.


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