API reference
BallisticsUtility
Static calculation helpers used by the simulator.
Source: src/Ballistics/BallisticsUtility.cs. DragGModel contains G1, G2, G5, G6, G7 and G8.
Vector3 GetWindVector(Vector3 windSpeedInMetrics, float delta)
Vector3 GetGravity(float gravityAcceleration, float delta)
float GetKineticEnergy(Vector3 velocity, float massInMetric)
void UpdateKEAndVelocity(ref Vector3 velocity, ref float kineticEnergy,
float mass, float newKE)
Vector3 GetDragVector(Vector3 currentVelocity, DragGModel gModel,
float ballisticCoef, float delta)
Vector3 GetSpinDrift(ref Vector3 previousDrift, double stabilityFactor,
float delta, float t)
double GetStability(float bulletLengthInMetrics, float bulletDiameterInMetrics,
float barrelTwistInMetrics, float bulletMassInMetrics,
float muzzleVelocityInMetrics, float airPressureInMetrics,
float temperatureInMetrics)
double GetRetardation(double velocityFPS, double ballisticCoef, DragGModel gModel)All methods are public static. The declarations above omit those modifiers for readability.
| Helper | Inputs and behaviour |
|---|---|
| GetWindVector | Takes km/h and step seconds. Returns wind × 0.1 × kmhToMS × delta; this is a scaled step contribution, not a pure km/h-to-m/s conversion. Runtime additionally multiplies it by elapsed travel time when updating position. |
| GetGravity | Returns (0, gravityAcceleration × delta, 0). |
| GetKineticEnergy | Velocity in m/s, mass in grams; returns joules using 0.5 × speed² × mass × 0.001. |
| UpdateKEAndVelocity | Clamps velocity magnitude to the value for the requested energy, then recomputes energy. It does not increase velocity above its current magnitude. |
| GetDragVector | Uses velocity, model, positive coefficient and step seconds to calculate the vector subtracted from velocity. |
| GetSpinDrift | Updates the previous-drift state passed by ref and returns a step-scaled difference. t is elapsed travel time. |
| GetStability | Length, diameter and twist in mm; mass in grams; muzzle speed in m/s; pressure in kPa; temperature in °C, matching the package's runtime fields. |
| GetRetardation | Takes speed in feet per second, coefficient and model. Used internally by GetDragVector. |
Prefer FireBallisticsBullet for normal integration. These helpers expose the package's approximations for custom simulation work; their names do not imply that returned values can be substituted directly into another physics solver.