use of org.hipparchus.analysis.differentiation.DSFactory in project Orekit by CS-SI.
the class TimeStampedFieldPVCoordinatesTest method testLinearConstructors.
@Test
public void testLinearConstructors() {
DSFactory factory = new DSFactory(6, 1);
TimeStampedFieldPVCoordinates<DerivativeStructure> pv1 = new TimeStampedFieldPVCoordinates<>(AbsoluteDate.CCSDS_EPOCH, createVector(1, 0.1, 10, 6), createVector(-1, -0.1, -10, 6), createVector(10, 1.0, 100, 6));
TimeStampedFieldPVCoordinates<DerivativeStructure> pv2 = new TimeStampedFieldPVCoordinates<>(AbsoluteDate.FIFTIES_EPOCH, createVector(2, 0.2, 20, 6), createVector(-2, -0.2, -20, 6), createVector(20, 2.0, 200, 6));
TimeStampedFieldPVCoordinates<DerivativeStructure> pv3 = new TimeStampedFieldPVCoordinates<>(AbsoluteDate.GALILEO_EPOCH, createVector(3, 0.3, 30, 6), createVector(-3, -0.3, -30, 6), createVector(30, 3.0, 300, 6));
TimeStampedFieldPVCoordinates<DerivativeStructure> pv4 = new TimeStampedFieldPVCoordinates<>(AbsoluteDate.JULIAN_EPOCH, createVector(4, 0.4, 40, 6), createVector(-4, -0.4, -40, 6), createVector(40, 4.0, 400, 6));
checkPV(pv4, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.JULIAN_EPOCH, 4, pv1), 1.0e-15);
checkPV(pv4, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.JULIAN_EPOCH, factory.constant(4), pv1), 1.0e-15);
checkPV(pv4, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.JULIAN_EPOCH, factory.constant(4), pv1.toPVCoordinates()), 1.0e-15);
checkPV(pv2, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.FIFTIES_EPOCH, pv1, pv3), 1.0e-15);
checkPV(pv3, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.GALILEO_EPOCH, 1, pv1, 1, pv2), 1.0e-15);
checkPV(pv3, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.GALILEO_EPOCH, factory.constant(1), pv1, factory.constant(1), pv2), 1.0e-15);
checkPV(pv3, new TimeStampedFieldPVCoordinates<>(AbsoluteDate.GALILEO_EPOCH, factory.constant(1), pv1.toPVCoordinates(), factory.constant(1), pv2.toPVCoordinates()), 1.0e-15);
checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 2, pv4), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 3, pv1, 1, pv2, 1, pv3), 1.0e-15);
checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 3, pv3), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 3, pv1, 1, pv2, 1, pv4), 1.0e-15);
checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 3, pv3), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, factory.constant(3), pv1, factory.constant(1), pv2, factory.constant(1), pv4), 1.0e-15);
checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 3, pv3), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, factory.constant(3), pv1.toPVCoordinates(), factory.constant(1), pv2.toPVCoordinates(), factory.constant(1), pv4.toPVCoordinates()), 1.0e-15);
checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 5, pv4), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 4, pv1, 3, pv2, 2, pv3, 1, pv4), 1.0e-15);
checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 5, pv4), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, factory.constant(4), pv1, factory.constant(3), pv2, factory.constant(2), pv3, factory.constant(1), pv4), 1.0e-15);
checkPV(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, 5, pv4), new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, factory.constant(4), pv1.toPVCoordinates(), factory.constant(3), pv2.toPVCoordinates(), factory.constant(2), pv3.toPVCoordinates(), factory.constant(1), pv4.toPVCoordinates()), 1.0e-15);
}
use of org.hipparchus.analysis.differentiation.DSFactory in project Orekit by CS-SI.
the class FieldPVCoordinatesTest method testGetMomentum.
@Test
public void testGetMomentum() {
// setup
DSFactory factory = new DSFactory(1, 1);
DerivativeStructure oneDS = factory.getDerivativeField().getOne();
DerivativeStructure zeroDS = factory.getDerivativeField().getZero();
FieldVector3D<DerivativeStructure> zero = new FieldVector3D<>(zeroDS, zeroDS, zeroDS);
FieldVector3D<DerivativeStructure> i = new FieldVector3D<>(oneDS, zeroDS, zeroDS);
FieldVector3D<DerivativeStructure> j = new FieldVector3D<>(zeroDS, oneDS, zeroDS);
FieldVector3D<DerivativeStructure> k = new FieldVector3D<>(zeroDS, zeroDS, oneDS);
FieldVector3D<DerivativeStructure> p = new FieldVector3D<>(oneDS, factory.constant(-2), factory.constant(3));
FieldVector3D<DerivativeStructure> v = new FieldVector3D<>(factory.constant(-9), factory.constant(8), factory.constant(-7));
// action + verify
Assert.assertEquals(new FieldPVCoordinates<>(p, v).getMomentum(), p.crossProduct(v));
// check simple cases
Assert.assertEquals(new FieldPVCoordinates<>(i, i.scalarMultiply(-1)).getMomentum(), zero);
Assert.assertEquals(new FieldPVCoordinates<>(i, j).getMomentum(), k);
}
use of org.hipparchus.analysis.differentiation.DSFactory in project Orekit by CS-SI.
the class FieldPVCoordinatesTest method testLinearConstructors.
@Test
public void testLinearConstructors() {
DSFactory factory = new DSFactory(6, 1);
FieldPVCoordinates<DerivativeStructure> pv1 = new FieldPVCoordinates<>(createVector(1, 0.1, 10, 6), createVector(-1, -0.1, -10, 6));
FieldPVCoordinates<DerivativeStructure> pv2 = new FieldPVCoordinates<>(createVector(2, 0.2, 20, 6), createVector(-2, -0.2, -20, 6));
FieldPVCoordinates<DerivativeStructure> pv3 = new FieldPVCoordinates<>(createVector(3, 0.3, 30, 6), createVector(-3, -0.3, -30, 6));
FieldPVCoordinates<DerivativeStructure> pv4 = new FieldPVCoordinates<>(createVector(4, 0.4, 40, 6), createVector(-4, -0.4, -40, 6));
checkPV(pv4, new FieldPVCoordinates<>(4, pv1), 1.0e-15);
checkPV(pv4, new FieldPVCoordinates<>(factory.constant(4), pv1), 1.0e-15);
checkPV(pv4, new FieldPVCoordinates<>(factory.constant(4), pv1.toPVCoordinates()), 1.0e-15);
checkPV(pv2, new FieldPVCoordinates<>(pv1, pv3), 1.0e-15);
checkPV(pv3, new FieldPVCoordinates<>(1, pv1, 1, pv2), 1.0e-15);
checkPV(pv3, new FieldPVCoordinates<>(factory.constant(1), pv1, factory.constant(1), pv2), 1.0e-15);
checkPV(pv3, new FieldPVCoordinates<>(factory.constant(1), pv1.toPVCoordinates(), factory.constant(1), pv2.toPVCoordinates()), 1.0e-15);
checkPV(new FieldPVCoordinates<>(2, pv4), new FieldPVCoordinates<>(3, pv1, 1, pv2, 1, pv3), 1.0e-15);
checkPV(new FieldPVCoordinates<>(3, pv3), new FieldPVCoordinates<>(3, pv1, 1, pv2, 1, pv4), 1.0e-15);
checkPV(new FieldPVCoordinates<>(3, pv3), new FieldPVCoordinates<>(factory.constant(3), pv1, factory.constant(1), pv2, factory.constant(1), pv4), 1.0e-15);
checkPV(new FieldPVCoordinates<>(3, pv3), new FieldPVCoordinates<>(factory.constant(3), pv1.toPVCoordinates(), factory.constant(1), pv2.toPVCoordinates(), factory.constant(1), pv4.toPVCoordinates()), 1.0e-15);
checkPV(new FieldPVCoordinates<>(5, pv4), new FieldPVCoordinates<>(4, pv1, 3, pv2, 2, pv3, 1, pv4), 1.0e-15);
checkPV(new FieldPVCoordinates<>(5, pv4), new FieldPVCoordinates<>(factory.constant(4), pv1, factory.constant(3), pv2, factory.constant(2), pv3, factory.constant(1), pv4), 1.0e-15);
checkPV(new FieldPVCoordinates<>(5, pv4), new FieldPVCoordinates<>(factory.constant(4), pv1.toPVCoordinates(), factory.constant(3), pv2.toPVCoordinates(), factory.constant(2), pv3.toPVCoordinates(), factory.constant(1), pv4.toPVCoordinates()), 1.0e-15);
}
use of org.hipparchus.analysis.differentiation.DSFactory in project Orekit by CS-SI.
the class FieldPVCoordinatesTest method testGetAngularVelocity.
@Test
public void testGetAngularVelocity() {
// setup
DSFactory factory = new DSFactory(1, 1);
DerivativeStructure oneDS = factory.getDerivativeField().getOne();
DerivativeStructure zeroDS = factory.getDerivativeField().getZero();
FieldVector3D<DerivativeStructure> zero = new FieldVector3D<>(zeroDS, zeroDS, zeroDS);
FieldVector3D<DerivativeStructure> i = new FieldVector3D<>(oneDS, zeroDS, zeroDS);
FieldVector3D<DerivativeStructure> j = new FieldVector3D<>(zeroDS, oneDS, zeroDS);
FieldVector3D<DerivativeStructure> k = new FieldVector3D<>(zeroDS, zeroDS, oneDS);
FieldVector3D<DerivativeStructure> p = new FieldVector3D<>(oneDS, factory.constant(-2), factory.constant(3));
FieldVector3D<DerivativeStructure> v = new FieldVector3D<>(factory.constant(-9), factory.constant(8), factory.constant(-7));
// action + verify
Assert.assertEquals(new FieldPVCoordinates<>(p, v).getAngularVelocity(), p.crossProduct(v).scalarMultiply(p.getNormSq().reciprocal()));
// check extra simple cases
Assert.assertEquals(new FieldPVCoordinates<>(i, i.scalarMultiply(-1)).getAngularVelocity(), zero);
Assert.assertEquals(new FieldPVCoordinates<>(i.scalarMultiply(2), j).getAngularVelocity(), k.scalarMultiply(0.5));
}
use of org.hipparchus.analysis.differentiation.DSFactory in project Orekit by CS-SI.
the class IERSConventionsTest method checkGMSTRate.
private void checkGMSTRate(final TimeScalarFunction gmst, final TimeScalarFunction gmstRate, final AbsoluteDate date, final double span, final double sampleStep, final double h, final double tolerance) throws OrekitException {
UnivariateDifferentiableFunction differentiated = new FiniteDifferencesDifferentiator(4, h).differentiate(new UnivariateFunction() {
@Override
public double value(final double dt) {
return gmst.value(date.shiftedBy(dt));
}
});
DSFactory factory = new DSFactory(1, 1);
double maxRateError = 0;
for (double dt = 0; dt < span; dt += sampleStep) {
double rateRef = differentiated.value(factory.variable(0, dt)).getPartialDerivative(1);
double rate = gmstRate.value(date.shiftedBy(dt));
maxRateError = FastMath.max(maxRateError, FastMath.abs(rateRef - rate));
}
Assert.assertEquals(0, maxRateError, tolerance);
}
Aggregations