List of usage examples for org.apache.commons.math3.geometry.euclidean.threed FieldVector3D FieldVector3D
public FieldVector3D(final double a, final FieldVector3D<T> u)
From source file:org.orekit.utils.FieldAngularCoordinatesTest.java
private FieldVector3D<DerivativeStructure> randomVector(Random random, double norm) { double n = random.nextDouble() * norm; double x = random.nextDouble(); double y = random.nextDouble(); double z = random.nextDouble(); return new FieldVector3D<DerivativeStructure>(n, createVector(x, y, z, 4).normalize()); }
From source file:org.orekit.utils.FieldPVCoordinates.java
/** Multiplicative constructor * <p>Build a PVCoordinates from another one and a scale factor.</p> * <p>The PVCoordinates built will be a * pv</p> * @param a scale factor//from ww w. ja v a 2 s . c o m * @param pv base (unscaled) PVCoordinates */ public FieldPVCoordinates(final double a, final FieldPVCoordinates<T> pv) { position = new FieldVector3D<T>(a, pv.position); velocity = new FieldVector3D<T>(a, pv.velocity); acceleration = new FieldVector3D<T>(a, pv.acceleration); }
From source file:org.orekit.utils.FieldPVCoordinates.java
/** Multiplicative constructor * <p>Build a PVCoordinates from another one and a scale factor.</p> * <p>The PVCoordinates built will be a * pv</p> * @param a scale factor//from w w w .ja v a2 s . c o m * @param pv base (unscaled) PVCoordinates */ public FieldPVCoordinates(final T a, final FieldPVCoordinates<T> pv) { position = new FieldVector3D<T>(a, pv.position); velocity = new FieldVector3D<T>(a, pv.velocity); acceleration = new FieldVector3D<T>(a, pv.acceleration); }
From source file:org.orekit.utils.FieldPVCoordinates.java
/** Multiplicative constructor * <p>Build a PVCoordinates from another one and a scale factor.</p> * <p>The PVCoordinates built will be a * pv</p> * @param a scale factor/*from w w w.java 2 s .c o m*/ * @param pv base (unscaled) PVCoordinates */ public FieldPVCoordinates(final T a, final PVCoordinates pv) { position = new FieldVector3D<T>(a, pv.getPosition()); velocity = new FieldVector3D<T>(a, pv.getVelocity()); acceleration = new FieldVector3D<T>(a, pv.getAcceleration()); }
From source file:org.orekit.utils.FieldPVCoordinates.java
/** Normalize the position part of the instance. * <p>// www . j a v a 2s . co m * The computed coordinates first component (position) will be a * normalized vector, the second component (velocity) will be the * derivative of the first component (hence it will generally not * be normalized), and the third component (acceleration) will be the * derivative of the second component (hence it will generally not * be normalized). * </p> * @return a new instance, with first component normalized and * remaining component computed to have consistent derivatives */ public FieldPVCoordinates<T> normalize() { final T inv = position.getNorm().reciprocal(); final FieldVector3D<T> u = new FieldVector3D<T>(inv, position); final FieldVector3D<T> v = new FieldVector3D<T>(inv, velocity); final FieldVector3D<T> w = new FieldVector3D<T>(inv, acceleration); final T uv = FieldVector3D.dotProduct(u, v); final T v2 = FieldVector3D.dotProduct(v, v); final T uw = FieldVector3D.dotProduct(u, w); final FieldVector3D<T> uDot = new FieldVector3D<T>(inv.getField().getOne(), v, uv.multiply(-1), u); final FieldVector3D<T> uDotDot = new FieldVector3D<T>(inv.getField().getOne(), w, uv.multiply(-2), v, uv.multiply(uv).multiply(3).subtract(v2).subtract(uw), u); return new FieldPVCoordinates<T>(u, uDot, uDotDot); }
From source file:org.orekit.utils.TimeStampedFieldAngularCoordinatesTest.java
@Test public void testShift() throws OrekitException { double rate = 2 * FastMath.PI / (12 * 60); TimeStampedFieldAngularCoordinates<DerivativeStructure> angularCoordinates = new TimeStampedFieldAngularCoordinates<DerivativeStructure>( AbsoluteDate.J2000_EPOCH, createRotation(1, 0, 0, 0, false), new FieldVector3D<DerivativeStructure>(rate, createVector(0, 0, 1, 4)), createVector(0, 0, 0, 4)); Assert.assertEquals(rate, angularCoordinates.getRotationRate().getNorm().getReal(), 1.0e-10); double dt = 10.0; double alpha = rate * dt; TimeStampedFieldAngularCoordinates<DerivativeStructure> shifted = angularCoordinates.shiftedBy(dt); Assert.assertEquals(rate, shifted.getRotationRate().getNorm().getReal(), 1.0e-10); Assert.assertEquals(alpha,// www . j av a 2 s . co m FieldRotation.distance(angularCoordinates.getRotation(), shifted.getRotation()).getReal(), 1.0e-10); FieldVector3D<DerivativeStructure> xSat = shifted.getRotation().applyInverseTo(createVector(1, 0, 0, 4)); Assert.assertEquals(0.0, xSat.subtract(createVector(FastMath.cos(alpha), FastMath.sin(alpha), 0, 4)).getNorm().getReal(), 1.0e-10); FieldVector3D<DerivativeStructure> ySat = shifted.getRotation().applyInverseTo(createVector(0, 1, 0, 4)); Assert.assertEquals(0.0, ySat.subtract(createVector(-FastMath.sin(alpha), FastMath.cos(alpha), 0, 4)).getNorm().getReal(), 1.0e-10); FieldVector3D<DerivativeStructure> zSat = shifted.getRotation().applyInverseTo(createVector(0, 0, 1, 4)); Assert.assertEquals(0.0, zSat.subtract(createVector(0, 0, 1, 4)).getNorm().getReal(), 1.0e-10); }
From source file:org.orekit.utils.TimeStampedFieldAngularCoordinatesTest.java
@Test public void testSpin() throws OrekitException { double rate = 2 * FastMath.PI / (12 * 60); TimeStampedFieldAngularCoordinates<DerivativeStructure> angularCoordinates = new TimeStampedFieldAngularCoordinates<DerivativeStructure>( AbsoluteDate.J2000_EPOCH, createRotation(0.48, 0.64, 0.36, 0.48, false), new FieldVector3D<DerivativeStructure>(rate, createVector(0, 0, 1, 4)), createVector(0, 0, 0, 4)); Assert.assertEquals(rate, angularCoordinates.getRotationRate().getNorm().getReal(), 1.0e-10); double dt = 10.0; TimeStampedFieldAngularCoordinates<DerivativeStructure> shifted = angularCoordinates.shiftedBy(dt); Assert.assertEquals(rate, shifted.getRotationRate().getNorm().getReal(), 1.0e-10); Assert.assertEquals(rate * dt,/* ww w . ja va2 s . c o m*/ FieldRotation.distance(angularCoordinates.getRotation(), shifted.getRotation()).getReal(), 1.0e-10); FieldVector3D<DerivativeStructure> shiftedX = shifted.getRotation() .applyInverseTo(createVector(1, 0, 0, 4)); FieldVector3D<DerivativeStructure> shiftedY = shifted.getRotation() .applyInverseTo(createVector(0, 1, 0, 4)); FieldVector3D<DerivativeStructure> shiftedZ = shifted.getRotation() .applyInverseTo(createVector(0, 0, 1, 4)); FieldVector3D<DerivativeStructure> originalX = angularCoordinates.getRotation() .applyInverseTo(createVector(1, 0, 0, 4)); FieldVector3D<DerivativeStructure> originalY = angularCoordinates.getRotation() .applyInverseTo(createVector(0, 1, 0, 4)); FieldVector3D<DerivativeStructure> originalZ = angularCoordinates.getRotation() .applyInverseTo(createVector(0, 0, 1, 4)); Assert.assertEquals(FastMath.cos(rate * dt), FieldVector3D.dotProduct(shiftedX, originalX).getReal(), 1.0e-10); Assert.assertEquals(FastMath.sin(rate * dt), FieldVector3D.dotProduct(shiftedX, originalY).getReal(), 1.0e-10); Assert.assertEquals(0.0, FieldVector3D.dotProduct(shiftedX, originalZ).getReal(), 1.0e-10); Assert.assertEquals(-FastMath.sin(rate * dt), FieldVector3D.dotProduct(shiftedY, originalX).getReal(), 1.0e-10); Assert.assertEquals(FastMath.cos(rate * dt), FieldVector3D.dotProduct(shiftedY, originalY).getReal(), 1.0e-10); Assert.assertEquals(0.0, FieldVector3D.dotProduct(shiftedY, originalZ).getReal(), 1.0e-10); Assert.assertEquals(0.0, FieldVector3D.dotProduct(shiftedZ, originalX).getReal(), 1.0e-10); Assert.assertEquals(0.0, FieldVector3D.dotProduct(shiftedZ, originalY).getReal(), 1.0e-10); Assert.assertEquals(1.0, FieldVector3D.dotProduct(shiftedZ, originalZ).getReal(), 1.0e-10); FieldVector3D<DerivativeStructure> forward = FieldAngularCoordinates .estimateRate(angularCoordinates.getRotation(), shifted.getRotation(), dt); Assert.assertEquals(0.0, forward.subtract(angularCoordinates.getRotationRate()).getNorm().getReal(), 1.0e-10); FieldVector3D<DerivativeStructure> reversed = FieldAngularCoordinates.estimateRate(shifted.getRotation(), angularCoordinates.getRotation(), dt); Assert.assertEquals(0.0, reversed.add(angularCoordinates.getRotationRate()).getNorm().getReal(), 1.0e-10); }
From source file:org.orekit.utils.TimeStampedFieldAngularCoordinatesTest.java
@Test public void testInterpolationRotationOnly() throws OrekitException { AbsoluteDate date = AbsoluteDate.GALILEO_EPOCH; double alpha0 = 0.5 * FastMath.PI; double omega = 0.5 * FastMath.PI; TimeStampedFieldAngularCoordinates<DerivativeStructure> reference = new TimeStampedFieldAngularCoordinates<DerivativeStructure>( date, createRotation(createVector(0, 0, 1, 4), alpha0), new FieldVector3D<DerivativeStructure>(omega, createVector(0, 0, -1, 4)), createVector(0, 0, 0, 4)); List<TimeStampedFieldAngularCoordinates<DerivativeStructure>> sample = new ArrayList<TimeStampedFieldAngularCoordinates<DerivativeStructure>>(); for (double dt : new double[] { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }) { FieldRotation<DerivativeStructure> r = reference.shiftedBy(dt).getRotation(); sample.add(new TimeStampedFieldAngularCoordinates<DerivativeStructure>(date.shiftedBy(dt), r, createVector(0, 0, 0, 4), createVector(0, 0, 0, 4))); }// ww w.j a va 2s . co m for (double dt = 0; dt < 1.0; dt += 0.001) { TimeStampedFieldAngularCoordinates<DerivativeStructure> interpolated = TimeStampedFieldAngularCoordinates .interpolate(date.shiftedBy(dt), AngularDerivativesFilter.USE_R, sample); FieldRotation<DerivativeStructure> r = interpolated.getRotation(); FieldVector3D<DerivativeStructure> rate = interpolated.getRotationRate(); FieldVector3D<DerivativeStructure> acceleration = interpolated.getRotationAcceleration(); Assert.assertEquals(0.0, FieldRotation.distance(reference.shiftedBy(dt).getRotation(), r).getReal(), 3.0e-4); Assert.assertEquals(0.0, FieldVector3D.distance(reference.shiftedBy(dt).getRotationRate(), rate).getReal(), 1.0e-2); Assert.assertEquals(0.0, FieldVector3D .distance(reference.shiftedBy(dt).getRotationAcceleration(), acceleration).getReal(), 1.0e-2); } }
From source file:org.orekit.utils.TimeStampedFieldAngularCoordinatesTest.java
@Test public void testInterpolationGTODIssue() throws OrekitException { AbsoluteDate t0 = new AbsoluteDate("2004-04-06T19:59:28.000", TimeScalesFactory.getTAI()); double[][] params = new double[][] { { 0.0, -0.3802356750911964, -0.9248896320037013, 7.292115030462892e-5 }, { 4.0, 0.1345716955788532, -0.990903859488413, 7.292115033301528e-5 }, { 8.0, -0.613127541102373, 0.7899839354960061, 7.292115037371062e-5 } }; List<TimeStampedFieldAngularCoordinates<DerivativeStructure>> sample = new ArrayList<TimeStampedFieldAngularCoordinates<DerivativeStructure>>(); for (double[] row : params) { AbsoluteDate t = t0.shiftedBy(row[0] * 3600.0); FieldRotation<DerivativeStructure> r = createRotation(row[1], 0.0, 0.0, row[2], false); FieldVector3D<DerivativeStructure> o = new FieldVector3D<DerivativeStructure>(row[3], createVector(0, 0, 1, 4)); sample.add(/*from ww w. j a v a2 s. c o m*/ new TimeStampedFieldAngularCoordinates<DerivativeStructure>(t, r, o, createVector(0, 0, 0, 4))); } for (double dt = 0; dt < 29000; dt += 120) { TimeStampedFieldAngularCoordinates<DerivativeStructure> shifted = sample.get(0).shiftedBy(dt); TimeStampedFieldAngularCoordinates<DerivativeStructure> interpolated = TimeStampedFieldAngularCoordinates .interpolate(t0.shiftedBy(dt), AngularDerivativesFilter.USE_RR, sample); Assert.assertEquals(0.0, FieldRotation.distance(shifted.getRotation(), interpolated.getRotation()).getReal(), 1.3e-7); Assert.assertEquals(0.0, FieldVector3D.distance(shifted.getRotationRate(), interpolated.getRotationRate()).getReal(), 1.0e-11); } }
From source file:org.orekit.utils.TimeStampedFieldPVCoordinates.java
/** Multiplicative constructor * <p>Build a PVCoordinates from another one and a scale factor.</p> * <p>The PVCoordinates built will be a * pv</p> * @param date date of the built coordinates * @param a scale factor//from www .j av a2 s .c om * @param pv base (unscaled) PVCoordinates */ public TimeStampedFieldPVCoordinates(final AbsoluteDate date, final double a, final FieldPVCoordinates<T> pv) { super(new FieldVector3D<T>(a, pv.getPosition()), new FieldVector3D<T>(a, pv.getVelocity()), new FieldVector3D<T>(a, pv.getAcceleration())); this.date = date; }