HI,
I am trying to use Orekit to compute the following:
Given a location on the surface of the Moon (latitude + longitude + altitude) and a given Date and Time:
- Find the locat azimuth and elevation of the Earth;
- Find the local azimuth and elevation of the Sun;
I have created the following code to do so:
…
CelestialBody moon = CelestialBodyFactory.getMoon();
// Define a GeodeticPoint at the location of the observer on the surface of the moon.
GeodeticPoint geodeticPoint = new GeodeticPoint(observerLatitude,observerLongitude, observerAltitude);
Frame moonFrame = moon.getBodyOrientedFrame();
BodyShape moonBodyShape = new OneAxisEllipsoid(Constants.MOON_EQUATORIAL_RADIUS, MOON_FLATTENING, moonFrame);
TopocentricFrame moonCentricLocation = new TopocentricFrame(moonBodyShape, geodeticPoint, "location");
AbsoluteDate absoluteDate = new AbsoluteDate(date, getUTCScale());
TimeStampedPVCoordinates earthCoordinatesInMoonFrame = earth.getPVCoordinates(absoluteDate, moonCentricLocation);
// Convert Sun position in Horizontal Coordinates.
earthCoordinates = convertToHorizontalCoordinates(earthCoordinatesInMoonFrame.getPosition());
private HorizontalCoordinates convertToHorizontalCoordinates(Vector3D positionInTopocentricFrame)
{
double r = positionInTopocentricFrame.getNorm();
double rXY = Math.sqrt(positionInTopocentricFrame.getX() * positionInTopocentricFrame.getX() +
positionInTopocentricFrame.getY() * positionInTopocentricFrame.getY());
double elevation = Math.atan((positionInTopocentricFrame.getZ() / rXY));
double azimuth = Math.toRadians(90) - Math.atan2(positionInTopocentricFrame.getY(), positionInTopocentricFrame.getX());
HorizontalCoordinates coordinates = ApogyCoreEnvironmentFactory.eINSTANCE.createHorizontalCoordinates();
coordinates.setAltitude(elevation);
coordinates.setAzimuth(azimuth);
coordinates.setRadius(r);
return coordinates;
}
I am getting values that are close to what I expect (based on calculation done in STK), but not quite (the elevation of the Earth can deviate by more than 10 degrees in certain cases, I can provide a csv file containing the expected and actual data if usefull).
So what I am doing wrong ?
Thanks !