Even perfect control fails if your state is wrong
A spacecraft orbit can be represented by classical orbital elements or by a Cartesian state vector. Both are correct, but the conversion is fragile. A degree/radian mistake, a swapped angle, or a singular element near circular/equatorial conditions can make the simulation look physically wrong.
wrong orbit + perfect controller → wrong correction
Debug the representation before blaming the solver
Convert orbital elements into perifocal position/velocity, then rotate into ECI.
Show how one unit mistake can create a new orbital plane and large state error.
Separate ellipse orientation from spacecraft position along the ellipse.
Distinguish rotating the orbital plane from rotating the ellipse inside the plane.
When e ≈ 0, argument of perigee loses physical meaning.
When i ≈ 0, RAAN becomes undefined and can jump numerically.
Six numbers, but not six independent visual ideas
Semi-major axis: orbit size.
Eccentricity: orbit shape.
Inclination: tilt of orbital plane.
RAAN: rotation of orbital plane around Earth.
Argument of perigee: ellipse orientation inside the plane.
True anomaly: spacecraft position measured from perigee.
Build the correct orbit, then introduce a controlled bug
Adjust the orbital elements and choose a bug mode. The plots compare the correct state against the bugged state. The diagnostic cards estimate whether the issue is a plane error, position error, unit error, or singularity.
The orbit begins in the perifocal plane
Classical orbital elements are first converted into position and velocity in the perifocal frame. The orbit is then rotated into the inertial frame using Ω, i, and ω.
A unit bug can create a different orbit
If code expects radians but receives degrees, an angle like 45° may be interpreted as 45 radians. This does not produce a small perturbation; it can rotate the orbital plane dramatically.
bugged: i = 45 rad
ω rotates the ellipse; ν moves the spacecraft
Controls where perigee lies inside the orbital plane.
Controls where the spacecraft is along the ellipse, measured from perigee.
Ω rotates the plane; ω rotates the ellipse inside the plane
Swapping RAAN and argument of perigee is a classic representation bug. The numbers may look reasonable, but the orbital plane, line of nodes, and perigee direction can all move.
ω → ellipse orientation within that plane
Sometimes the element is not physically meaningful
There is no unique perigee, so argument of perigee becomes undefined. Use argument of latitude:
u = ω + ν
There is no clear line of nodes, so RAAN becomes undefined. Use longitude of perigee or true longitude.
ϖ = Ω + ω
l = Ω + ω + ν
Use error patterns to identify the bug
Likely angle interpretation problem.
Likely RAAN or inclination issue.
Likely true anomaly or epoch issue.
Equatorial singularity.
Circular orbit singularity.
Likely degree/radian or unit bug.
Code patterns for conversion and diagnostics
These snippets show the core operations used in the interactive page: perifocal conversion, rotation to ECI, and diagnostic checks.
% COE to perifocal position and velocity
mu = 398600.4418;
p = a*(1 - e^2);
r_pqw = [p*cos(nu)/(1 + e*cos(nu));
p*sin(nu)/(1 + e*cos(nu));
0];
v_pqw = sqrt(mu/p)*[-sin(nu);
e + cos(nu);
0];
% Rotate from PQW to ECI
R3_Omega = R3(Omega);
R1_i = R1(i);
R3_omega = R3(omega);
Q_pqw_to_eci = R3_Omega * R1_i * R3_omega;
r_eci = Q_pqw_to_eci * r_pqw;
v_eci = Q_pqw_to_eci * v_pqw;
% Diagnostic checks
energy = 0.5*dot(v,v) - mu/norm(r);
h_vec = cross(r,v);
h_hat = h_vec/norm(h_vec);
plane_error = acosd(dot(h_hat_correct, h_hat_bugged));
position_error = norm(r_correct - r_bugged);
velocity_error = norm(v_correct - v_bugged);
Before trusting propagation or control, validate the state
Degrees and radians are one of the fastest ways to create a false orbit.
They rotate different geometry and should not be interchanged.
Circular and equatorial orbits make some classical elements undefined.
Use energy, angular momentum, and plane-normal checks.
Different bugs produce different diagnostic signatures.
A controller can only act on the state representation it receives.