Hi! I’m new to using oerkit. A situation has arisen, I have the coordinates of the satellite’s position in XYZ relative to the center of the earth on WGS84, and I need to determine whether it is illuminated by the sun or is in an eclipse. I will be very grateful for any help! I tried to use Eclipse Detector, but I get very strange results. I’ll attach the code.
public class CalculateSunlight {
private static double equatorialRadius = Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
private static double polarRadius = Constants.WGS84_EARTH_FLATTENING;
private CelestialBody earth;
public CalculateSunlight() {
initialFrame();
}
public double calculateSunlight(double x, double y, double z, double vx, double vy, double vz, AbsoluteDate dateTime){
EclipseDetector eclipseDetector = buildEclipseDetector();
return eclipseDetector.g(createSpacecraftState(x, y, z, vx, vy, vz, dateTime));
}
public EclipseDetector buildEclipseDetector() throws OrekitException {
final double SUN_EQUATORIAL_RADIUS = 696000000;
CelestialBody earth = CelestialBodyFactory.getEarth();
OneAxisEllipsoid earthShape = new OneAxisEllipsoid(equatorialRadius, polarRadius, earth.getBodyOrientedFrame());
PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
EclipseDetector detector = new EclipseDetector(sun, SUN_EQUATORIAL_RADIUS, earthShape);
return detector;
}
private SpacecraftState createSpacecraftState(double x, double y, double z, double vx, double vy, double vz, AbsoluteDate dateTime) {
Vector3D position = new Vector3D(x, y, z);
Vector3D velosity = new Vector3D(vx, vy, vz);
AbsolutePVCoordinates absolutePVCoordinates = new AbsolutePVCoordinates(earth.getInertiallyOrientedFrame(), dateTime, position, velosity);
return new SpacecraftState(absolutePVCoordinates);
}
private void initialFrame() {
this.earth = CelestialBodyFactory.getEarth();
}
}