Skip to main content

Kinematics

The KinematicsExtensions class provides a set of extension methods for performing common kinematic calculations in both scalar and vector form. It covers free fall, constant velocity, constant acceleration, time-independent SUVAT equations, and circular motion.

⬇️ Free Fall​

Compute the velocity or time of a freely falling object:

v=2gh,t=2hgv = \sqrt{2gh}, \quad t = \sqrt{\frac{2h}{g}}

double v = 10.0.FreeFallVelocity();       // scalar: v = sqrt(2*g*h)
double t = 10.0.FreeFallTime(); // scalar: t = sqrt(2*h/g)

// Vector version with optional direction (default downward)
Vector dir = new Vector(0,0,-1);
Vector vVec = 10.0.FreeFallVelocity(dir);

➑️ Constant Velocity​

Compute position given constant velocity:

s=s0+vβ‹…ts = s_0 + v \cdot t

double s = 3.0.PositionFromConstantVelocity(time: 5, initialPosition: 2); 

Vector velocity = new Vector(2, 0, 0);
Vector initialPosition = new Vector(1, 0, 0);
Vector position = velocity.PositionFromConstantVelocity(4, initialPosition);

πŸš€ Constant Acceleration​

Compute velocity or position under constant acceleration:

v=v0+at,s=s0+v0t+12at2v = v_0 + at, \quad s = s_0 + v_0 t + \tfrac{1}{2}at^2

// Scalar
double v = 2.0.VelocityFromConstantAcceleration(time: 4, initialVelocity: 1);
double s = 2.0.PositionFromConstantAcceleration(time: 3, initialVelocity: 1, initialPosition: 0);

// Vector
Vector a = new Vector(1, 0, 0);
Vector v0 = new Vector(0, 0, 0);
Vector s0 = new Vector(0, 0, 0);

Vector vVec = a.VelocityFromConstantAcceleration(3, v0);
Vector sVec = a.PositionFromConstantAcceleration(2, v0, s0);

⏱️ Time-Independent (SUVAT) Equations​

Compute kinematics without explicit time:

v2=v02+2aβ‹…s,s=v2βˆ’v022av^2 = v_0^2 + 2a \cdot s, \quad s = \frac{v^2 - v_0^2}{2a}

double finalV = 2.0.VelocityFromDisplacement(5, initialVelocity: 1);
double displacement = 2.0.DisplacementFromVelocities(finalVelocity: 5, initialVelocity: 1);
double t = 2.0.TimeToReachVelocity(finalVelocity: 5, initialVelocity: 1);
double sAvg = 3.0.DisplacementFromAverageVelocity(initialVelocity: 2, finalVelocity: 4);

// Vector versions are also supported
Vector a = new Vector(2, 0, 0);
Vector s = new Vector(3, 0, 0);
Vector v0 = new Vector(1, 0, 0);

Vector finalVVec = a.VelocityFromDisplacement(s, v0);
Vector displacementVec = a.DisplacementFromVelocities(finalVVec, v0);

πŸ”„ Circular Motion​

Compute centripetal acceleration:

ac=v2ra_c = \frac{v^2}{r}

double a = 3.0.CentripetalAcceleration(radius: 2); // scalar

Vector velocity = new Vector(2, 0, 0);
Vector radius = new Vector(0, 3, 0);
Vector ac = velocity.CentripetalAcceleration(radius); // vector, towards center

Angular speed, period, and frequency:

double omega = 10.0.AngularSpeed(radius: 5);  // Ο‰ = v/r = 2 rad/s
double T = 10.0.Period(radius: 5); // T = 2Ο€r/v
double f = 10.0.Frequency(radius: 5); // f = v/(2Ο€r) = 1/T

Angular velocity vector and tangential velocity:

// Object at (5,0,0) moving at (0,10,0) β†’ angular velocity along +Z
Vector omega = vel.AngularVelocity(radius); // Ο‰ = (r Γ— v) / |r|Β²

// Reverse: angular velocity β†’ tangential velocity
Vector v = omega.TangentialVelocity(radius); // v = Ο‰ Γ— r

🎯 Projectile Motion​

Compute projectile trajectory, time of flight, maximum height, and range:

rβƒ—(t)=rβƒ—0+vβƒ—0t+12g⃗ t2,T=2v0sin⁑θg,H=v02sin⁑2ΞΈ2g,R=v02sin⁑2ΞΈg\vec{r}(t) = \vec{r}_0 + \vec{v}_0 t + \tfrac{1}{2}\vec{g}\,t^2, \quad T = \frac{2v_0\sin\theta}{g}, \quad H = \frac{v_0^2\sin^2\theta}{2g}, \quad R = \frac{v_0^2\sin 2\theta}{g}

Create an initial velocity vector from speed and launch angle:

// 20 m/s at 45Β° β†’ vβ‚€ = (vΒ·cos(ΞΈ), 0, vΒ·sin(ΞΈ))
Vector v0 = 20.0.ProjectileVelocityFromAngle(Math.PI / 4);

Position and velocity at any time:

Vector pos = v0.ProjectilePosition(time: 1.5);
Vector vel = v0.ProjectileVelocity(time: 1.5);

// With initial height (e.g. launched from a 10m cliff)
Vector pos2 = v0.ProjectilePosition(time: 1.5, initialHeight: 10);

Time of flight, maximum height, and range:

// Vector versions (support initial height)
double T = v0.ProjectileTimeOfFlight();
double H = v0.ProjectileMaxHeight();
double R = v0.ProjectileRange();

// With elevated launch
double T2 = v0.ProjectileTimeOfFlight(initialHeight: 10);
double R2 = v0.ProjectileRange(initialHeight: 10);

// Scalar versions (speed + angle, same-height launch)
double T3 = 20.0.ProjectileTimeOfFlight(Math.PI / 4); // T = 2vβ‚€sin(ΞΈ)/g
double H3 = 20.0.ProjectileMaxHeight(Math.PI / 4); // H = vβ‚€Β²sinΒ²(ΞΈ)/(2g)
double R3 = 20.0.ProjectileRange(Math.PI / 4); // R = vβ‚€Β²sin(2ΞΈ)/g

🌍 Orbital Mechanics​

Gravitational and circular-orbit calculations:

g=GMr2,F=Gm1m2r2,vesc=2GMr,vorb=GMr,T=2Ο€r3GMg = \frac{GM}{r^2}, \quad F = \frac{Gm_1 m_2}{r^2}, \quad v_{esc} = \sqrt{\frac{2GM}{r}}, \quad v_{orb} = \sqrt{\frac{GM}{r}}, \quad T = 2\pi\sqrt{\frac{r^3}{GM}}

Gravitational helpers:

// Gravitational field strength at distance r from a mass: g = GM/rΒ²
double g = PhysicsConstants.EarthMass.GravitationalFieldStrength(PhysicsConstants.EarthRadius);

// Gravitational force between two masses: F = GΒ·m₁·mβ‚‚/rΒ²
double F = PhysicsConstants.EarthMass.GravitationalForce(PhysicsConstants.MoonMass, 3.844e8);

// Escape velocity: v = √(2GM/r)
double vEsc = PhysicsConstants.EarthMass.EscapeVelocity(PhysicsConstants.EarthRadius);

Circular orbit scalars:

double r = PhysicsConstants.EarthRadius + 408000; // ISS altitude

double speed = PhysicsConstants.EarthMass.OrbitalSpeed(r); // v = √(GM/r) β‰ˆ 7660 m/s
double period = PhysicsConstants.EarthMass.OrbitalPeriod(r); // T = 2Ο€βˆš(rΒ³/GM) β‰ˆ 92 min

Position, velocity, and acceleration on a circular orbit at time tt:

double M = PhysicsConstants.EarthMass;
double r = 1e7; // 10 000 km radius

Vector pos = M.OrbitalPosition(r, time); // RΒ·(cos Ο‰t, sin Ο‰t, 0)
Vector vel = M.OrbitalVelocity(r, time); // Rω·(-sin Ο‰t, cos Ο‰t, 0)
Vector acc = M.OrbitalAcceleration(r, time); // -ω²RΒ·(cos Ο‰t, sin Ο‰t, 0)

πŸ”€ Relative Motion​

Compute relative kinematics between two objects or reference frames:

vβƒ—rel=vβƒ—Aβˆ’vβƒ—B,rβƒ—rel=rβƒ—Aβˆ’rβƒ—B,aβƒ—rel=aβƒ—Aβˆ’aβƒ—B\vec{v}_{rel} = \vec{v}_A - \vec{v}_B, \quad \vec{r}_{rel} = \vec{r}_A - \vec{r}_B, \quad \vec{a}_{rel} = \vec{a}_A - \vec{a}_B

var vA = new Vector(30, 0, 0);
var vB = new Vector(-20, 0, 0);

Vector vRel = vA.RelativeVelocity(vB); // v_A - v_B = (50, 0, 0)
Vector rRel = posA.RelativePosition(posB); // r_A - r_B
Vector aRel = accA.RelativeAcceleration(accB); // a_A - a_B

Closing speed (positive = approaching, negative = separating):

double cs = vA.ClosingSpeed(vB, posA, posB);

Position in a moving reference frame over time:

Vector relPos = vObj.RelativePositionAtTime(vRef, time: 5.0, r0Obj, r0Ref);

Closest approach between two objects at constant velocity:

double t   = vA.TimeOfClosestApproach(vB, posA, posB);
double d = vA.MinimumDistance(vB, posA, posB);