use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class FieldPVCoordinatesTest method testJounceIsAccelerationSecondDerivative.
@Test
public void testJounceIsAccelerationSecondDerivative() throws OrekitException {
final FieldCartesianOrbit<Decimal64> orbit = new FieldCartesianOrbit<>(new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(-4947831.), new Decimal64(-3765382.), new Decimal64(-3708221.)), new FieldVector3D<>(new Decimal64(-2079.), new Decimal64(5291.), new Decimal64(-7842.))), FramesFactory.getEME2000(), FieldAbsoluteDate.getJ2000Epoch(Decimal64Field.getInstance()), Constants.EIGEN5C_EARTH_MU);
FieldPVCoordinates<FieldDerivativeStructure<Decimal64>> fv = orbit.getPVCoordinates().toDerivativeStructurePV(2);
FieldVector3D<Decimal64> numericalJounce = differentiate(orbit, o -> {
FieldVector3D<FieldDerivativeStructure<Decimal64>> a = o.getPVCoordinates().toDerivativeStructurePV(1).getAcceleration();
return new FieldVector3D<>(a.getX().getPartialDerivative(1), a.getY().getPartialDerivative(1), a.getZ().getPartialDerivative(1));
});
Assert.assertEquals(numericalJounce.getX().getReal(), fv.getAcceleration().getX().getPartialDerivative(2).getReal(), 1.0e-15);
Assert.assertEquals(numericalJounce.getY().getReal(), fv.getAcceleration().getY().getPartialDerivative(2).getReal(), 1.0e-15);
Assert.assertEquals(numericalJounce.getZ().getReal(), fv.getAcceleration().getZ().getPartialDerivative(2).getReal(), 1.0e-15);
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D 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.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class FieldPVCoordinatesTest method testToDerivativeStructureVector2.
@Test
public void testToDerivativeStructureVector2() throws OrekitException {
FieldVector3D<FieldDerivativeStructure<Decimal64>> fv = new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(1), new Decimal64(0.1), new Decimal64(10)), new FieldVector3D<>(new Decimal64(-1), new Decimal64(-0.1), new Decimal64(-10)), new FieldVector3D<>(new Decimal64(10), new Decimal64(-1.0), new Decimal64(-100))).toDerivativeStructureVector(2);
Assert.assertEquals(1, fv.getX().getFreeParameters());
Assert.assertEquals(2, fv.getX().getOrder());
Assert.assertEquals(1.0, fv.getX().getReal(), 1.0e-10);
Assert.assertEquals(0.1, fv.getY().getReal(), 1.0e-10);
Assert.assertEquals(10.0, fv.getZ().getReal(), 1.0e-10);
Assert.assertEquals(-1.0, fv.getX().getPartialDerivative(1).getReal(), 1.0e-15);
Assert.assertEquals(-0.1, fv.getY().getPartialDerivative(1).getReal(), 1.0e-15);
Assert.assertEquals(-10.0, fv.getZ().getPartialDerivative(1).getReal(), 1.0e-15);
Assert.assertEquals(10.0, fv.getX().getPartialDerivative(2).getReal(), 1.0e-15);
Assert.assertEquals(-1.0, fv.getY().getPartialDerivative(2).getReal(), 1.0e-15);
Assert.assertEquals(-100.0, fv.getZ().getPartialDerivative(2).getReal(), 1.0e-15);
checkPV(new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(1), new Decimal64(0.1), new Decimal64(10)), new FieldVector3D<>(new Decimal64(-1), new Decimal64(-0.1), new Decimal64(-10)), new FieldVector3D<>(new Decimal64(10), new Decimal64(-1.0), new Decimal64(-100))), new FieldPVCoordinates<>(fv), 1.0e-15);
for (double dt = 0; dt < 10; dt += 0.125) {
FieldVector3D<Decimal64> p = new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(1), new Decimal64(0.1), new Decimal64(10)), new FieldVector3D<>(new Decimal64(-1), new Decimal64(-0.1), new Decimal64(-10)), new FieldVector3D<>(new Decimal64(10), new Decimal64(-1.0), new Decimal64(-100))).shiftedBy(dt).getPosition();
Assert.assertEquals(p.getX().doubleValue(), fv.getX().taylor(dt).doubleValue(), 1.0e-14);
Assert.assertEquals(p.getY().doubleValue(), fv.getY().taylor(dt).doubleValue(), 1.0e-14);
Assert.assertEquals(p.getZ().doubleValue(), fv.getZ().taylor(dt).doubleValue(), 1.0e-14);
}
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class CartesianOrbit method getVelocityDS.
/**
* Get velocity with derivatives.
* @return velocity with derivatives
*/
private FieldVector3D<DerivativeStructure> getVelocityDS() {
final Vector3D v = getPVCoordinates().getVelocity();
final Vector3D a = getPVCoordinates().getAcceleration();
return new FieldVector3D<>(FACTORY.build(v.getX(), a.getX()), FACTORY.build(v.getY(), a.getY()), FACTORY.build(v.getZ(), a.getZ()));
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class Geoid method getIntersectionPoint.
/**
* {@inheritDoc}
*
* <p> The intersection point is computed using a line search along the
* specified line. This is accurate when the geoid is slowly varying.
*/
@Override
public <T extends RealFieldElement<T>> FieldGeodeticPoint<T> getIntersectionPoint(final FieldLine<T> lineInFrame, final FieldVector3D<T> closeInFrame, final Frame frame, final FieldAbsoluteDate<T> date) throws OrekitException {
final Field<T> field = date.getField();
/*
* It is assumed that the geoid is slowly varying over it's entire
* surface. Therefore there will one local intersection.
*/
// transform to body frame
final Frame bodyFrame = this.getBodyFrame();
final FieldTransform<T> frameToBody = frame.getTransformTo(bodyFrame, date);
final FieldVector3D<T> close = frameToBody.transformPosition(closeInFrame);
final FieldLine<T> lineInBodyFrame = frameToBody.transformLine(lineInFrame);
// set the line's direction so the solved for value is always positive
final FieldLine<T> line;
if (lineInBodyFrame.getAbscissa(close).getReal() < 0) {
line = lineInBodyFrame.revert();
} else {
line = lineInBodyFrame;
}
final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
// calculate end points
// distance from line to center of earth, squared
final T d2 = line.pointAt(0.0).getNormSq();
// the minimum abscissa, squared
final double n = ellipsoid.getPolarRadius() + MIN_UNDULATION;
final T minAbscissa2 = d2.negate().add(n * n);
// smaller end point of the interval = 0.0 or intersection with
// min_undulation sphere
final T lowPoint = minAbscissa2.getReal() < 0 ? field.getZero() : minAbscissa2.sqrt();
// the maximum abscissa, squared
final double x = ellipsoid.getEquatorialRadius() + MAX_UNDULATION;
final T maxAbscissa2 = d2.negate().add(x * x);
// larger end point of the interval
final T highPoint = maxAbscissa2.sqrt();
// line search function
final RealFieldUnivariateFunction<T> heightFunction = z -> {
try {
final FieldGeodeticPoint<T> geodetic = transform(line.pointAt(z), bodyFrame, date);
return geodetic.getAltitude();
} catch (OrekitException e) {
// due to frame transform -> re-throw
throw new RuntimeException(e);
}
};
// compute answer
if (maxAbscissa2.getReal() < 0) {
// ray does not pierce bounding sphere -> no possible intersection
return null;
}
// solve line search problem to find the intersection
final FieldBracketingNthOrderBrentSolver<T> solver = new FieldBracketingNthOrderBrentSolver<>(field.getZero().add(1.0e-14), field.getZero().add(1.0e-6), field.getZero().add(1.0e-15), 5);
try {
final T abscissa = solver.solve(MAX_EVALUATIONS, heightFunction, lowPoint, highPoint, AllowedSolution.ANY_SIDE);
// return intersection point
return this.transform(line.pointAt(abscissa), bodyFrame, date);
} catch (MathRuntimeException e) {
// no intersection
return null;
}
}
Aggregations