Hello everyone,
I understand that RotationConvention
can be tricky to understand at first but are an important feature of the way Hipparchus handles rotations, however I have an issue with the convention used in Rotation.applyTo(Vector3D)
. It seems natural to me that it should follow the VECTOR_OPERATOR
convention since we apply the rotation to the vector and the Javadoc of this RotationConvention
reads:
According to this convention, the rotation moves vectors with respect to a fixed reference frame.
The Javadoc then gives a test case:
This means that if we define rotation r is a 90 degrees rotation around the Z axis, the image of vector
Vector3D.PLUS_I
would beVector3D.PLUS_J
However, I tested this statement in the following test :
public class RotationTest {
private static final double EPSILON = 1e-6;
@Test
public void testRotationConvention() {
// Given
final Rotation halfPiAroundPlusK = generateHalfPiAroundPlusKRotation();
// When
final Vector3D computedVector = halfPiAroundPlusK.applyTo(Vector3D.PLUS_I);
// Then
final Vector3D expectedVector = Vector3D.PLUS_J;
compareVector(expectedVector, computedVector);
}
private Rotation generateHalfPiAroundPlusKRotation() {
final double halfSqrtTwo = FastMath.sqrt(2) / 2;
return new Rotation(halfSqrtTwo, 0, 0, halfSqrtTwo, false);
}
private void compareVector(final Vector3D expectedVector, final Vector3D computedVector) {
Assert.assertArrayEquals(expectedVector.toArray(), computedVector.toArray(), EPSILON);
}
}
which fails, as the computedVector
is equal to Vector3D.MINUS_J
, which is the expected result if the Rotation.applyTo(Vector3D)
method follows the FRAME_TRANSFORM
convention.
I find this counterintuitive. I know that Rotation.applyInverseTo
gives me the answer I look for, but it seems odd to me that VECTOR_OPERATOR
is associated with Rotation.applyInverseTo(Vector3D)
and FRAME_TRANSFORM
is associated with Rotation.applyTo(Vector3D)
where intuition and Javadoc would point to the opposite. Maybe adding a method Rotation.applyTo(Vector3D, RotationConvention)
could help users wrap their heads around it? Although it does not solve the aforementioned confusion.
Have I missed something in my train of thought? Thank you in advance for your answers.
Cheers,
Guillaume