Added methods for geographic coordinate conversions.

This commit is contained in:
Chris Laurel 2001-05-25 04:53:06 +00:00
parent ba9cecf27c
commit 4f3e8fdda2
2 changed files with 43 additions and 0 deletions

View file

@ -214,6 +214,44 @@ Point3d Body::getHeliocentricPosition(double when)
}
Quatd Body::getEclipticalToEquatorial()
{
Quatd q(1);
q.xrotate(obliquity);
return q;
}
Quatd Body::getEclipticalToGeographic(double when)
{
return getEclipticalToEquatorial() * getEquatorialToGeographic(when);
}
// The geographic coordinate system has an origin at the center of the
// body, y-axis parallel to the rotation axis, x-axis through the prime
// meridian, and z-axis at a right angle the xy plane. An object with
// constant geographic coordinates will thus remain fixed with respect
// to a point on the surface of the body.
Quatd Body::getEquatorialToGeographic(double when)
{
double rotations = when / (double) getRotationPeriod();
int wholeRotations = (int) rotations;
double remainder = rotations - wholeRotations;
Quatd q(1);
q.yrotate(-remainder * 2 * PI - getRotationPhase());
return q;
}
Mat4d Body::getGeographicToHeliocentric(double when)
{
return getEquatorialToGeographic(when).toMatrix4() *
getLocalToHeliocentric(when);
}
#define SOLAR_IRRADIANCE 1367.6
#define SOLAR_POWER 3.8462e26

View file

@ -16,6 +16,7 @@
#include "surface.h"
#include "orbit.h"
#include "star.h"
#include "quaternion.h"
class Body;
@ -114,6 +115,10 @@ class Body
Mat4d getLocalToHeliocentric(double when);
Point3d getHeliocentricPosition(double when);
Quatd getEquatorialToGeographic(double when);
Quatd getEclipticalToEquatorial();
Quatd getEclipticalToGeographic(double when);
Mat4d getGeographicToHeliocentric(double when);
private:
std::string name;