Precessing ellipses
Posted: 09.03.2004, 18:11
I'm trying to model the orbits of Phobos and Deimos as precessing ellipses using the parameters on this page:
http://ssd.jpl.nasa.gov/sat_elem.html#legend
I'm completely frustrated . . . I can't understand why this code (written for clarity, not performance) doesn't work:
Hopefully, the code is close enough to mathematical notation that it makes sense even if you're not familiar with C++. Can anyone see what I'm missing here? The precession of the node and pericenter seem wrong to me--they're causing Deimos to move slightly faster than it does in my Horizons-derived sampled orbit.
--Chris
http://ssd.jpl.nasa.gov/sat_elem.html#legend
I'm completely frustrated . . . I can't understand why this code (written for clarity, not performance) doesn't work:
Code: Select all
Point3d computePosition(double jd) const
{
double epoch = 2433283.0 - 0.5; // 00:00 1 Jan 1950
double a = 23460.0;
double e = 0.0002;
double w0 = 290.496;
double M0 = 296.230;
double i = 1.793;
double node0 = 339.600;
double n = 285.1618919;
double Pw = 26.892;
double Pnode = 54.536;
double refplane_RA = 316.700;
double refplane_Dec = 53.564;
double marspole_RA = 317.681;
double marspole_Dec = 52.886;
double t = jd - epoch;
double T = t / 365.25;
double M = degToRad(M0 + n * t);
double w = degToRad(w0 + 360.0 * T / Pw);
double node = degToRad(node0 + 360.0 * T / Pnode);
// Solve Kepler's equation--for a low eccentricity orbit, just a few
// iterations is enough.
double E = M;
for (int k = 0; k < 3; k++)
E = M + e * sin(E);
// Compute the position in the orbital plane (y = 0)
double x = a * (cos(E) - e);
double z = a * sqrt(1 - square(e)) * -sin(E);
// Orientation of the orbital plane with respect to the Laplacian plane
Mat3d Rorbit = (Mat3d::yrotation(node) *
Mat3d::xrotation(degToRad(i)) *
Mat3d::yrotation(w));
// Rotate to the Earth's equatorial plane
double N = degToRad(refplane_RA);
double J = degToRad(90 - refplane_Dec);
Mat3d RLaplacian = (Mat3d::yrotation( N) *
Mat3d::xrotation( J) *
Mat3d::yrotation(-N));
// Rotate to the Martian equatorial plane
N = degToRad(marspole_RA);
J = degToRad(90 - marspole_Dec);
Mat3d RMars_eq = (Mat3d::yrotation( N) *
Mat3d::xrotation(-J) *
Mat3d::yrotation(-N));
Point3d p = Rorbit * Point3d(x, 0.0, z);
p = RLaplacian * p;
p = RMars_eq * p;
return p;
}
Hopefully, the code is close enough to mathematical notation that it makes sense even if you're not familiar with C++. Can anyone see what I'm missing here? The precession of the node and pericenter seem wrong to me--they're causing Deimos to move slightly faster than it does in my Horizons-derived sampled orbit.
--Chris