The comet's true anomaly θ is advanced every frame by dθ/dt = h/r², where h = √(GM·a·(1−e²)) is the constant specific angular momentum fixed by the orbit's semi-major axis a and eccentricity e. Because h never changes over an orbit, the swept area dA = ½r²dθ is exactly constant per unit time — Kepler's second law falls straight out of the integration instead of being drawn in separately. Speed follows the vis-viva equation, v² = GM(2/r − 1/a), so the comet visibly accelerates as it dives toward perihelion and coasts near aphelion.
The tail is two independent particle streams spawned at the nucleus every frame: a fast, narrow ion tail that launches straight along the Sun→comet direction, and a slower, wider dust tail that launches along a blend of that same radial direction with a slight lag opposite the comet's current heading. Because both streams are seeded from the radial (Sun→comet) unit vector rather than from the velocity vector, the tail always points away from the Sun — before, during and after perihelion — regardless of which way the comet itself is travelling at that instant. Spawn rate and particle lifetime both scale with 1/r, so the tail visibly grows as the comet nears the Sun and fades again as it withdraws, matching the real inverse-distance falloff of solar heating and sublimation.
dθ/dt = h / r² (Kepler's 2nd law, by construction)
v² = GM(2/r - 1/a) (vis-viva speed)
tailDir = normalize(cometPos - sunPos) (always anti-sunward)