Handles scaling between: GE: internal values used in the physics integrators Scene: values in Unity units (raw Unity position values and game time seconds) World: The chosen units for values in inspector entries etc. (e.g. AU, km, m) SI: Metric system values.
More...
|
static void | Init () |
|
static double | UpdateMassScale (Units units, float timeScale, float lengthScale) |
| The integrators in GE do not provide Newton's constant G as part of the force calculation.
|
|
static float | GetGameSecondPerPhysicsSecond () |
|
static float | ScalePeriod (float period) |
|
static float | ScaleToGameSeconds (float time) |
| Scale a physics time to Unity game seconds.
|
|
static float | GameSecToWorldTime (float gameSec) |
|
static Vector3 | ScaleAcceleration (Vector3 a, float lengthScale, float timeScale) |
| Modify the physics engine acceleration to appear in world scale units.
|
|
static double | AccelerationScaleInternalToGEUnits () |
|
static float | GetVelocityScale () |
| Factor to convert GE units (SOLAR, ORBITAL) to GE internal velocity units.
|
|
static void | ScaleScene (Units units, 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.
|
|
static float | ScaleDistancePhyToScene (float distance) |
| Convert a distance in GE physics units to scene (Unity) units.
|
|
static Vector3d | ScaleVector3dPhyToScene (Vector3d v) |
| Convert a distance in GE physics units to scene (Unity) units.
|
|
static Vector3 | ScalePositionSceneToPhys (Vector3 pos) |
|
static void | ScaleNBody (NBody nbody, Units units, float lengthScale) |
| Scales the N body using the provided units and length scale.
|
|
static Vector3 | ScaleVelSceneToPhys (Vector3 vel) |
| Scale the velocity in Unity scene units (e.g. suitable for a rigidbody) into GE interal units.
|
|
static Vector3d | ScaleVelSceneToPhys (Vector3d vel) |
|
static Vector3 | ScaleGEVelocityToSI (Vector3 v) |
|
static Vector3d | ScaleGEVelocityToSI (Vector3d v) |
|
static Vector3 | ScaleGEPositionToSI (Vector3 v) |
|
static Vector3d | ScaleGEPositionToSI (Vector3d v) |
|
static Vector3 | ScaleVelPhysToScene (Vector3 vel) |
| Scale the velocity from internal phys units to scene units.
|
|
static double | ScaleVelPhysMagnitudeToScene (double vel) |
|
static Vector3d | ScaleVelPhysToScene (Vector3d vel) |
|
static double | AccelSItoGEUnits () |
| Provide conversion factor to convert acceleration in SI units to the GE units in use by Gravity Engine.
|
|
static double | AccelGEtoSIUnits () |
| Determine the factor to convert acceleration to SI units.
|
|
static double | PositionScaletoSIUnits () |
| Determine the factor to convert scaled position to SI units.
|
|
static double | VelocityScaletoSIUnits () |
| Determine the factor to convert scaled velocity to SI units.
|
|
static double | AccelGEtoInternalUnits () |
| Provide the conversion factor to convert acceleration from GE units (e.g. km/hr^2 if ORBITAL) into the internal units. The internal units are determined based on the timeScale and lengthScale chosen.
|
|
static string | LengthUnits (Units units) |
| Return the string indicating the length units in use by the gravity engine.
|
|
static string | VelocityUnits (Units units) |
| Return the string indicating the velocity units in use by the gravity engine.
|
|
static string | MassUnits (Units units) |
| Return the string indicating the mass units in use by the gravity engine.
|
|
static string | GetWorldTimeFormatted (double physTime, Units units) |
| Return the world time in the selected units as a string.
|
|
static System.TimeSpan | GetTimeSpan (double physTime, Units units) |
| Return the time as a C# TimeSpan object. Used in code to show Calendar date for the evolution. Typically in SOLAR or ORBITAL units.
|
|
static double | GetWorldTimeSeconds (double physTime) |
| Return the world time in the selected units as a double.
|
|
static double | WorldSecsToPhysTime (double worldSecs) |
|
static double | WorldTimeToPhysTime (double worldTime) |
| Convert the world time in GravityEngine units to GE internal phys time.
|
|
Handles scaling between: GE: internal values used in the physics integrators Scene: values in Unity units (raw Unity position values and game time seconds) World: The chosen units for values in inspector entries etc. (e.g. AU, km, m) SI: Metric system values.
The GE inspector allows for four choices of units, with different inspector inputs in each case: -DIMENSIONLESS:
- mass scale -SI: (m/kg/sec)
- Unity units per m (lengthScale)
- Game sec. per SI sec. (timeScale) -ORBITAL (km/1E24 kg/hour)
- Unity units per km (lengthScale)
- game sec. per world hour (timeScale) -SOLAR (AU/1E24 kg/year)
- Unity units per AU (lengthScale)
- game sec. per world year (timeScale)
Components that specifiy initial positions (e.g. OrbitEllipse) interpret the values provided as World units and convert them to internal GE units when they are added to GE. A position specified for a NBody in the inspector will indicate the active choice of units and set the NBody initialPos field. Scripts can set this field in world units directly.
GravityEngine.lengthScale specifies the Unity units per World unit value. For dimensionless units it is 1.
GravityEngine.timescale specifies game seconds per World time unit. For dimensionless units it is 1.
The internal units for mass and time do not in general align with any of the world unit choices. This is a consequence of choosing to implement the gravity calculations in which the gravitational constant G=1 (this represents a specific choice of internal units, since we are always free to scale units to make G=1). This adjustment is made by UpdateTimeScale. Length is not changed, so length in World units match internal lengths (scene position differs by lengthScale).
Scaling When Adding an NBody
position: (initialPos is specified in the NBody inspector in World units) nbody.initialPhyPos = nbody.initialPos * lengthScale; r = nbody.initialPhyPos/ phyToWorldFactor; (phyToWorldFactor allows dynamic scaling from a value in the GE inspector)
velocity: vel_phys = nbody.vel * velocityScale;
mass: m = nbody.mass * massScale;
mass_scale is set by UpdateMassScale
const float GravityScaler.G = 6.67408E-11f |
|
static |
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.