Why angle between SC +Z Axis and Nadir is not 0

		<groupId>org.orekit</groupId>
		<artifactId>orekit</artifactId>
		<version>12.2</version>

// — Hardcoded Orbit Creation for Test —
double a = 6914864.595028313;
double e = 0.0013732273450863008;
double i = FastMath.toRadians(97.31192000786449);
double raan = FastMath.toRadians(206.92345786678513);
double aop = FastMath.toRadians(110.07566872906646);
double lm = FastMath.toRadians(59.0859835217772);
AbsoluteDate testStartDate = new AbsoluteDate(2025, 5, 6, 8, 10, 18.0, TimeScalesFactory.getUTC());

    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
            Constants.WGS84_EARTH_FLATTENING, itrf);

    // Create the test orbit directly here
    Frame inertialFrame = FramesFactory.getEME2000();
    Orbit testOrbit = new KeplerianOrbit(a, e, i, raan, aop, lm,
            PositionAngleType.MEAN, inertialFrame,
            testStartDate, Constants.EGM96_EARTH_MU);

    // --- Direct Test of NadirPointing Attitude with the hardcoded testOrbit ---
    PVCoordinates pvFromTestOrbit = testOrbit.getPVCoordinates(inertialFrame);
    AttitudeProvider nadirProviderTest = new NadirPointing(inertialFrame, earth);
    Attitude nadirAttitudeTest = nadirProviderTest.getAttitude(testOrbit, testOrbit.getDate(), inertialFrame);
    Vector3D scZAxisInertialTest = nadirAttitudeTest.getRotation().applyTo(Vector3D.PLUS_K);
    Vector3D nadirVectorInertialTest = pvFromTestOrbit.getPosition().negate();
    double directNadirAngle = Vector3D.angle(scZAxisInertialTest, nadirVectorInertialTest);
    System.out.println("--- Direct NadirPointing Test (Hardcoded Orbit) ---");
    System.out.println("Angle between SC +Z Axis and Nadir (Inertial, Direct Test): " + FastMath.toDegrees(directNadirAngle) + " degrees.");
    System.out.println("---------------------------------");

debug info:
— Direct NadirPointing Test (Hardcoded Orbit) —
Angle between SC +Z Axis and Nadir (Inertial, Direct Test): 9.459028337671722 degrees.

I guess this should be

nadirAttitudeTest.getRotation().applyInverseTo(Vector3D.PLUS_K)
1 Like

oh, my god, yes! why? is Vector3D.PLUS_K toward earth center, isn’t it?

Yes, for Nadir pointing PLUS_K points towards the Earth. The problem was that the attitude is the rotation that transforms inertial vectors into spacecraft vectors, so when you start from spacecraft vector PLUS_K, and want its coordinates in inertial frame, you have to apply the inverse of the attitude rotation.

1 Like