You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that performing Hermite interpolation at sample point can give slightly different results (~1e-8) which should not happen.
Attached test to reproduce the issue
import org.hipparchus.analysis.interpolation.HermiteInterpolator;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
public class IssueHermiteInterpolatorHipparchus {
public static void main(String[] args) {
// GIVEN
// Data points
final Vector3D pos1 = new Vector3D(6503514.0,
1239647.0,
-717490.0);
final Vector3D vel1 = new Vector3D(-873.1600000000001,
8740.42,
-4191.076);
final Vector3D acc1 = new Vector3D(-8.78857042491286,
-1.6934422560847768,
0.9818410863212799);
final Vector3D pos2 = new Vector3D(-1.1065513874477834E7,
1.2731407944126774E7,
-5910755.440081692);
final Vector3D vel2 = new Vector3D(-4415.112289029152,
-154.58334977152364,
159.60303091130456);
final Vector3D acc2 = new Vector3D(0.7725072019312011,
-0.8888003812990051,
0.41281521337323207);
// Create interpolator
final HermiteInterpolator interpolator = new HermiteInterpolator();
// Add data to interpolator
interpolator.addSamplePoint(0, pos1.toArray(), vel1.toArray(), acc1.toArray());
interpolator.addSamplePoint(1, pos2.toArray(), vel2.toArray(), acc2.toArray());
// WHEN
// Interpolate at data points
final double[][] interpolated1 = interpolator.derivatives(0, 2);
final double[][] interpolated2 = interpolator.derivatives(1, 2);
// THEN
// Create equivalent PV
final Vector3D interpolatedPos1 = new Vector3D(interpolated1[0][0],
interpolated1[0][1],
interpolated1[0][2]);
final Vector3D interpolatedVel1 = new Vector3D(interpolated1[1][0],
interpolated1[1][1],
interpolated1[1][2]);
final Vector3D interpolatedAcc1 = new Vector3D(interpolated1[2][0],
interpolated1[2][1],
interpolated1[2][2]);
final Vector3D interpolatedPos2 = new Vector3D(interpolated2[0][0],
interpolated2[0][1],
interpolated2[0][2]);
final Vector3D interpolatedVel2 = new Vector3D(interpolated2[1][0],
interpolated2[1][1],
interpolated2[1][2]);
final Vector3D interpolatedAcc2 = new Vector3D(interpolated2[2][0],
interpolated2[2][1],
interpolated2[2][2]);
// Show difference with data points
System.out.println("Difference with PV1");
System.out.println(pos1.subtract(interpolatedPos1));
System.out.println(vel1.subtract(interpolatedVel1));
System.out.println(acc1.subtract(interpolatedAcc1));
System.out.println();
System.out.println("Difference with PV2");
System.out.println(pos2.subtract(interpolatedPos2));
System.out.println(vel2.subtract(interpolatedVel2));
System.out.println(acc2.subtract(interpolatedAcc2));
}
}
Cheers,
Vincent
The text was updated successfully, but these errors were encountered:
Hello everyone,
I noticed that performing Hermite interpolation at sample point can give slightly different results (~1e-8) which should not happen.
Attached test to reproduce the issue
Cheers,
Vincent
The text was updated successfully, but these errors were encountered: