Skip to content

Documentation / @interstellar-tools/equations / cwHillDerivatives

Function: cwHillDerivatives() ​

ts
function cwHillDerivatives(state: CwState, n: number): CwStateDerivative;

Defined in: orbits/cw-hill-derivatives.ts:67

Compute the time-derivative of a Clohessy–Wiltshire / Hill relative-motion state (right-hand side for ODE integration).

This function is intended to be used with a numerical integrator (RK4, Dormand–Prince, etc.) to propagate the relative motion of a deputy spacecraft about a chief on a near-circular reference orbit, expressed in the LVLH frame:

  • x: radial (outward from the central body)
  • y: along-track (tangential / direction of motion)
  • z: cross-track (orbit-normal)

Governing equations (CW/Hill):

x¨−2ny˙−3n2x=0y¨+2nx˙=0z¨+n2z=0

Rearranged into explicit accelerations:

x¨=2ny˙+3n2x,y¨=−2nx˙,z¨=−n2z

Input state: state = [x, y, z, xDot, yDot, zDot]

Output derivative: dstate/dt = [xDot, yDot, zDot, xDDot, yDDot, zDDot]

Units (consistent):

  • Position: m or km
  • Velocity: m/s or km/s
  • Mean motion n: rad/s
  • Acceleration: m/s² or km/s²

Parameters ​

ParameterTypeDescription
stateCwStateCW/Hill state [x, y, z, xDot, yDot, zDot] (all finite).
nnumberMean motion n of the reference orbit (finite, >= 0), in rad/s.

Returns ​

CwStateDerivative

Time derivative of state as [xDot, yDot, zDot, xDDot, yDDot, zDDot].

Throws ​

If n or any state component is not finite.

Throws ​

If n < 0.

Example ​

ts
import { meanMotion, cwHillDerivatives, type CwState } from '...';

const mu = 398600.4418; // km³/s²
const a = 7000; // km
const n = meanMotion(a, mu); // rad/s

const s: CwState = [100, 0, 0, 0, 0.01, 0];
const ds = cwHillDerivatives(s, n);
// feed ds into your integrator (RK4, etc.)