Angular coordinates interpolation around PI
It seems to me that there is an issue when interpolating angular
coordinates around PI. The test below reproduces the observed anomaly
(it can be added to AngularCoordinatesTest.java):
@Test
public void testInterpolationAroundPI() throws OrekitException {
List<Pair<AbsoluteDate,AngularCoordinates>>sample = new ArrayList<Pair<AbsoluteDate,AngularCoordinates>>();
// add angular coordinates at t0: 179.999 degrees rotation along X
axis
AbsoluteDate t0 = new AbsoluteDate("2012-01-01T00:00:00.000",
TimeScalesFactory.getTAI());
AngularCoordinates ac0 = new AngularCoordinates(new
Rotation(Vector3D.PLUS_I,FastMath.toRadians(179.999)), new
Vector3D(FastMath.toRadians(0),0,0));
sample.add(new Pair<AbsoluteDate, AngularCoordinates>(t0, ac0));
// add angular coordinates at t1: -179.999 degrees rotation (= 180.001
degrees) along X axis
AbsoluteDate t1 = new AbsoluteDate("2012-01-01T00:00:02.000",
TimeScalesFactory.getTAI());
AngularCoordinates ac1 = new AngularCoordinates(new
Rotation(Vector3D.PLUS_I,FastMath.toRadians(-179.999)), new
Vector3D(FastMath.toRadians(0),0,0));
sample.add(new Pair<AbsoluteDate, AngularCoordinates>(t1, ac1));
// get interpolated angular coordinates at mid time between t0 and t1
AbsoluteDate t = new AbsoluteDate("2012-01-01T00:00:01.000",
TimeScalesFactory.getTAI());
AngularCoordinates interpolated = AngularCoordinates.interpolate(t,
false, sample);
Assert.assertEquals(FastMath.toRadians(180), interpolated.getRotation().getAngle(), 1.0e-12);
}
I have the impression that the following piece of source code from getModifiedRodrigues method is causing the problem:
// make sure all interpolated points will be on the same branch
if (q0 < 0) {
q0 = -q0;
q1 = -q1;
q2 = -q2;
q3 = -q3;
}
I have a temporary solution (probably not very elegant) for myself as
follows:
// make sure all interpolated points will be on the same branch
if (q0*ref.getRotation().getQ0()<0 ||
fixed.getRotation().getAxis().dotProduct(ref.getRotation().getAxis())<0)
{
q0 = -q0;
q1 = -q1;
q2 = -q2;
q3 = -q3;
}
with "ref" being a new argument for getModifiedRodrigues method
representing the first AngularCoordinates used in interpolation. I can
provide more details if required.
(from redmine: issue id 173, created on 2014-06-11, closed on 2015-01-12)
- Uploads: