List of usage examples for org.apache.commons.math3.geometry.euclidean.threed FieldVector3D subtract
public FieldVector3D<T> subtract(final Vector3D v)
From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java
/** Get solar array normal in spacecraft frame. * @param date current date/*from w w w. jav a 2 s .co m*/ * @param frame inertial reference frame for state (both orbit and attitude) * @param position position of spacecraft in reference frame * @param rotation orientation (attitude) of the spacecraft with respect to reference frame * @return solar array normal in spacecraft frame * @exception OrekitException if sun direction cannot be computed in best lightning * configuration */ public synchronized FieldVector3D<DerivativeStructure> getNormal(final AbsoluteDate date, final Frame frame, final FieldVector3D<DerivativeStructure> position, final FieldRotation<DerivativeStructure> rotation) throws OrekitException { final DerivativeStructure one = position.getX().getField().getOne(); if (referenceDate != null) { // use a simple rotation at fixed rate final DerivativeStructure alpha = one.multiply(rotationRate * date.durationFrom(referenceDate)); return new FieldVector3D<DerivativeStructure>(alpha.cos(), saX, alpha.sin(), saY); } // compute orientation for best lightning final FieldVector3D<DerivativeStructure> sunInert = position .subtract(sun.getPVCoordinates(date, frame).getPosition()).negate().normalize(); final FieldVector3D<DerivativeStructure> sunSpacecraft = rotation.applyTo(sunInert); final DerivativeStructure d = FieldVector3D.dotProduct(sunSpacecraft, saZ); final DerivativeStructure f = d.multiply(d).subtract(1).negate(); if (f.getValue() < Precision.EPSILON) { // extremely rare case: the sun is along solar array rotation axis // (there will not be much output power ...) // we set up an arbitrary normal return new FieldVector3D<DerivativeStructure>(one, saZ.orthogonal()); } final DerivativeStructure s = f.sqrt().reciprocal(); return new FieldVector3D<DerivativeStructure>(s, sunSpacecraft) .subtract(new FieldVector3D<DerivativeStructure>(s.multiply(d), saZ)); }
From source file:org.orekit.forces.gravity.ThirdBodyAttraction.java
/** {@inheritDoc} */ public FieldVector3D<DerivativeStructure> accelerationDerivatives(final AbsoluteDate date, final Frame frame, final FieldVector3D<DerivativeStructure> position, final FieldVector3D<DerivativeStructure> velocity, final FieldRotation<DerivativeStructure> rotation, final DerivativeStructure mass) throws OrekitException { // compute bodies separation vectors and squared norm final Vector3D centralToBody = body.getPVCoordinates(date, frame).getPosition(); final double r2Central = centralToBody.getNormSq(); final FieldVector3D<DerivativeStructure> satToBody = position.subtract(centralToBody).negate(); final DerivativeStructure r2Sat = satToBody.getNormSq(); // compute relative acceleration final FieldVector3D<DerivativeStructure> satAcc = new FieldVector3D<DerivativeStructure>( r2Sat.sqrt().multiply(r2Sat).reciprocal().multiply(gm), satToBody); final Vector3D centralAcc = new Vector3D(gm / (r2Central * FastMath.sqrt(r2Central)), centralToBody); return satAcc.subtract(centralAcc); }
From source file:org.orekit.forces.radiation.SolarRadiationPressure.java
/** {@inheritDoc} */ public FieldVector3D<DerivativeStructure> accelerationDerivatives(final AbsoluteDate date, final Frame frame, final FieldVector3D<DerivativeStructure> position, final FieldVector3D<DerivativeStructure> velocity, final FieldRotation<DerivativeStructure> rotation, final DerivativeStructure mass) throws OrekitException { final FieldVector3D<DerivativeStructure> sunSatVector = position .subtract(sun.getPVCoordinates(date, frame).getPosition()); final DerivativeStructure r2 = sunSatVector.getNormSq(); // compute flux final double ratio = getLightningRatio(position.toVector3D(), frame, date); final DerivativeStructure rawP = r2.reciprocal().multiply(kRef * ratio); final FieldVector3D<DerivativeStructure> flux = new FieldVector3D<DerivativeStructure>( rawP.divide(r2.sqrt()), sunSatVector); // compute acceleration with all its partial derivatives return spacecraft.radiationPressureAcceleration(date, frame, position, rotation, mass, flux); }
From source file:org.orekit.utils.FieldAngularCoordinatesTest.java
@Test public void testShift() throws OrekitException { double rate = 2 * FastMath.PI / (12 * 60); FieldAngularCoordinates<DerivativeStructure> angularCoordinates = new FieldAngularCoordinates<DerivativeStructure>( 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; FieldAngularCoordinates<DerivativeStructure> shifted = angularCoordinates.shiftedBy(dt); Assert.assertEquals(rate, shifted.getRotationRate().getNorm().getReal(), 1.0e-10); Assert.assertEquals(alpha,/*ww w .j ava2s .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.FieldAngularCoordinatesTest.java
@Test public void testSpin() throws OrekitException { double rate = 2 * FastMath.PI / (12 * 60); FieldAngularCoordinates<DerivativeStructure> angularCoordinates = new FieldAngularCoordinates<DerivativeStructure>( 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; FieldAngularCoordinates<DerivativeStructure> shifted = angularCoordinates.shiftedBy(dt); Assert.assertEquals(rate, shifted.getRotationRate().getNorm().getReal(), 1.0e-10); Assert.assertEquals(rate * dt,/* ww w. j a v a2 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 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,/* w ww .j a va2s. com*/ 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.j ava 2 s .co 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); }