Example usage for org.apache.commons.math3.geometry.euclidean.threed Rotation applyTo

List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Rotation applyTo

Introduction

In this page you can find the example usage for org.apache.commons.math3.geometry.euclidean.threed Rotation applyTo.

Prototype

public Rotation applyTo(Rotation r) 

Source Link

Document

Apply the instance to another rotation.

Usage

From source file:org.orekit.frames.MODProviderTest.java

@Test
public void testEuler2000() throws OrekitException {

    // this alternate representation of the transform
    // is from equation 33 in IERS conventions 2003
    TransformProvider eulerBasedProvider = new TransformProvider() {
        private static final long serialVersionUID = 1L;
        private final PolynomialNutation<DerivativeStructure> zetaA = new PolynomialNutation<DerivativeStructure>(
                2.5976176 * Constants.ARC_SECONDS_TO_RADIANS, 2306.0809506 * Constants.ARC_SECONDS_TO_RADIANS,
                0.3019015 * Constants.ARC_SECONDS_TO_RADIANS, 0.0179663 * Constants.ARC_SECONDS_TO_RADIANS,
                -0.0000327 * Constants.ARC_SECONDS_TO_RADIANS, -0.0000002 * Constants.ARC_SECONDS_TO_RADIANS);
        private final PolynomialNutation<DerivativeStructure> thetaA = new PolynomialNutation<DerivativeStructure>(
                0.0, 2004.1917476 * Constants.ARC_SECONDS_TO_RADIANS,
                -0.4269353 * Constants.ARC_SECONDS_TO_RADIANS, -0.0418251 * Constants.ARC_SECONDS_TO_RADIANS,
                -0.0000601 * Constants.ARC_SECONDS_TO_RADIANS, -0.0000001 * Constants.ARC_SECONDS_TO_RADIANS);
        private final PolynomialNutation<DerivativeStructure> zA = new PolynomialNutation<DerivativeStructure>(
                -2.5976176 * Constants.ARC_SECONDS_TO_RADIANS, 2306.0803226 * Constants.ARC_SECONDS_TO_RADIANS,
                1.0947790 * Constants.ARC_SECONDS_TO_RADIANS, 0.0182273 * Constants.ARC_SECONDS_TO_RADIANS,
                0.0000470 * Constants.ARC_SECONDS_TO_RADIANS, -0.0000003 * Constants.ARC_SECONDS_TO_RADIANS);

        public Transform getTransform(AbsoluteDate date) {
            final double tc = IERSConventions.IERS_2003.evaluateTC(date);
            final Rotation r1 = new Rotation(Vector3D.PLUS_K, zA.value(tc));
            final Rotation r2 = new Rotation(Vector3D.PLUS_J, -thetaA.value(tc));
            final Rotation r3 = new Rotation(Vector3D.PLUS_K, zetaA.value(tc));
            return new Transform(date, r1.applyTo(r2.applyTo(r3)));
        }//from   ww w  . j  a v  a 2s . c om
    };

    MODProvider modProvider = new MODProvider(IERSConventions.IERS_2003);

    for (double dt = -Constants.JULIAN_CENTURY; dt < Constants.JULIAN_CENTURY; dt += 50
            * Constants.JULIAN_DAY) {
        AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt);
        Transform t = new Transform(date, modProvider.getTransform(date).getInverse(),
                eulerBasedProvider.getTransform(date));
        Assert.assertEquals(0, t.getRotation().getAngle(), 6.6e-13);
    }

}

From source file:org.orekit.frames.TODProvider.java

/** Get the transform from Mean Of Date at specified date.
 * <p>The update considers the nutation effects from IERS data.</p>
 * @param date new value of the date//w  ww  .  j  a  v  a2s . c om
 * @return transform at the specified date
 * @exception OrekitException if the nutation model data embedded in the
 * library cannot be read
 */
public Transform getTransform(final AbsoluteDate date) throws OrekitException {

    // compute nutation angles
    final double[] angles = nutationFunction.value(date);

    // compute the mean obliquity of the ecliptic
    final double moe = obliquityFunction.value(date);

    double dpsi = angles[0];
    double deps = angles[1];
    if (eopHistory != null) {
        // apply the corrections for the nutation parameters
        final double[] correction = eopHistory.getEquinoxNutationCorrection(date);
        dpsi += correction[0];
        deps += correction[1];
    }

    // compute the true obliquity of the ecliptic
    final double toe = moe + deps;

    // set up the elementary rotations for nutation
    final Rotation r1 = new Rotation(Vector3D.PLUS_I, toe);
    final Rotation r2 = new Rotation(Vector3D.PLUS_K, dpsi);
    final Rotation r3 = new Rotation(Vector3D.PLUS_I, -moe);

    // complete nutation
    final Rotation nutation = r1.applyTo(r2.applyTo(r3));

    // set up the transform from parent MOD
    return new Transform(date, nutation);

}

From source file:org.orekit.frames.Transform.java

/** Compute a composite rotation.
 * @param first first applied transform/* w w  w . jav  a2  s  . co  m*/
 * @param second second applied transform
 * @return rotation part of the composite transform
 */
private static Rotation compositeRotation(final Transform first, final Transform second) {

    final Rotation r1 = first.angular.getRotation();
    final Rotation r2 = second.angular.getRotation();

    return r2.applyTo(r1);

}

From source file:org.orekit.frames.Transform.java

/** Compute a composite rotation rate.
 * @param first first applied transform//from w ww.  ja v a 2 s.  com
 * @param second second applied transform
 * @return rotation rate part of the composite transform
 */
private static Vector3D compositeRotationRate(final Transform first, final Transform second) {

    final Vector3D o1 = first.angular.getRotationRate();
    final Rotation r2 = second.angular.getRotation();
    final Vector3D o2 = second.angular.getRotationRate();

    return o2.add(r2.applyTo(o1));

}

From source file:org.orekit.frames.Transform.java

/** Compute a composite rotation acceleration.
 * @param first first applied transform//  w  w w.  j  av  a  2 s. com
 * @param second second applied transform
 * @return rotation acceleration part of the composite transform
 */
private static Vector3D compositeRotationAcceleration(final Transform first, final Transform second) {

    final Vector3D o1 = first.angular.getRotationRate();
    final Vector3D oDot1 = first.angular.getRotationAcceleration();
    final Rotation r2 = second.angular.getRotation();
    final Vector3D o2 = second.angular.getRotationRate();
    final Vector3D oDot2 = second.angular.getRotationAcceleration();

    return new Vector3D(1, oDot2, 1, r2.applyTo(oDot1), -1, Vector3D.crossProduct(o2, r2.applyTo(o1)));

}

From source file:org.orekit.frames.Transform.java

/** Get the inverse transform of the instance.
 * @return inverse transform of the instance
 *///from   w w  w . j a va  2s.  c  om
public Transform getInverse() {

    final Rotation r = angular.getRotation();
    final Vector3D o = angular.getRotationRate();
    final Vector3D oDot = angular.getRotationAcceleration();
    final Vector3D rp = r.applyTo(cartesian.getPosition());
    final Vector3D rv = r.applyTo(cartesian.getVelocity());
    final Vector3D ra = r.applyTo(cartesian.getAcceleration());

    final Vector3D pInv = rp.negate();
    final Vector3D crossP = Vector3D.crossProduct(o, rp);
    final Vector3D vInv = crossP.subtract(rv);
    final Vector3D crossV = Vector3D.crossProduct(o, rv);
    final Vector3D crossDotP = Vector3D.crossProduct(oDot, rp);
    final Vector3D crossCrossP = Vector3D.crossProduct(o, crossP);
    final Vector3D aInv = new Vector3D(-1, ra, 2, crossV, 1, crossDotP, -1, crossCrossP);

    return new Transform(date, new PVCoordinates(pInv, vInv, aInv), angular.revert());

}

From source file:org.orekit.models.earth.tessellation.AlongTrackAiming.java

/** {@inheritDoc} */
@Override/*from   www .java  2s. c o  m*/
public Vector3D alongTileDirection(final Vector3D point, final GeodeticPoint gp) throws OrekitException {

    final double lStart = halfTrack.get(0).getFirst().getLatitude();
    final double lEnd = halfTrack.get(halfTrack.size() - 1).getFirst().getLatitude();
    // check the point can be reached
    if (gp.getLatitude() < FastMath.min(lStart, lEnd) || gp.getLatitude() > FastMath.max(lStart, lEnd)) {
        throw new OrekitException(OrekitMessages.OUT_OF_RANGE_LATITUDE, FastMath.toDegrees(gp.getLatitude()),
                FastMath.toDegrees(FastMath.min(lStart, lEnd)), FastMath.toDegrees(FastMath.max(lStart, lEnd)));
    }

    // bracket the point in the half track sample
    int iInf = 0;
    int iSup = halfTrack.size() - 1;
    while (iSup - iInf > 1) {
        final int iMiddle = (iSup + iInf) / 2;
        if ((lStart < lEnd) ^ (halfTrack.get(iMiddle).getFirst().getLatitude() > gp.getLatitude())) {
            // the specified latitude is in the second half
            iInf = iMiddle;
        } else {
            // the specified latitude is in the first half
            iSup = iMiddle;
        }
    }

    // ensure we can get points at iStart, iStart + 1, iStart + 2 and iStart + 3
    final int iStart = FastMath.max(0, FastMath.min(iInf - 1, halfTrack.size() - 4));

    // interpolate ground sliding point at specified latitude
    final HermiteInterpolator interpolator = new HermiteInterpolator();
    for (int i = iStart; i < iStart + 4; ++i) {
        final Vector3D position = halfTrack.get(i).getSecond().getPosition();
        final Vector3D velocity = halfTrack.get(i).getSecond().getVelocity();
        interpolator.addSamplePoint(halfTrack.get(i).getFirst().getLatitude(), new double[] { position.getX(),
                position.getY(), position.getZ(), velocity.getX(), velocity.getY(), velocity.getZ() });
    }
    final DerivativeStructure[] p = interpolator.value(new DerivativeStructure(1, 1, 0, gp.getLatitude()));

    // extract interpolated ground position/velocity
    final Vector3D position = new Vector3D(p[0].getValue(), p[1].getValue(), p[2].getValue());
    final Vector3D velocity = new Vector3D(p[3].getValue(), p[4].getValue(), p[5].getValue());

    // adjust longitude to match the specified one
    final Rotation rotation = new Rotation(Vector3D.PLUS_K, position, Vector3D.PLUS_K, point);
    final Vector3D fixedVelocity = rotation.applyTo(velocity);

    // the tile direction is aligned with sliding point velocity
    return fixedVelocity.normalize();

}

From source file:org.orekit.utils.AngularCoordinates.java

/** Estimate rotation rate between two orientations.
 * <p>Estimation is based on a simple fixed rate rotation
 * during the time interval between the two orientations.</p>
 * @param start start orientation/*ww w  .j a  va2 s.c o m*/
 * @param end end orientation
 * @param dt time elapsed between the dates of the two orientations
 * @return rotation rate allowing to go from start to end orientations
 */
public static Vector3D estimateRate(final Rotation start, final Rotation end, final double dt) {
    final Rotation evolution = start.applyTo(end.revert());
    return new Vector3D(evolution.getAngle() / dt, evolution.getAxis());
}

From source file:org.orekit.utils.AngularCoordinates.java

/** Get a time-shifted state.
 * <p>/*from   www. j  a  va 2s.  c om*/
 * The state can be slightly shifted to close dates. This shift is based on
 * an approximate solution of the fixed acceleration motion. It is <em>not</em>
 * intended as a replacement for proper attitude propagation but should be
 * sufficient for either small time shifts or coarse accuracy.
 * </p>
 * @param dt time shift in seconds
 * @return a new state, shifted with respect to the instance (which is immutable)
 */
public AngularCoordinates shiftedBy(final double dt) {

    // the shiftedBy method is based on a local approximation.
    // It considers separately the contribution of the constant
    // rotation, the linear contribution or the rate and the
    // quadratic contribution of the acceleration. The rate
    // and acceleration contributions are small rotations as long
    // as the time shift is small, which is the crux of the algorithm.
    // Small rotations are almost commutative, so we append these small
    // contributions one after the other, as if they really occurred
    // successively, despite this is not what really happens.

    // compute the linear contribution first, ignoring acceleration
    // BEWARE: there is really a minus sign here, because if
    // the target frame rotates in one direction, the vectors in the origin
    // frame seem to rotate in the opposite direction
    final double rate = rotationRate.getNorm();
    final Rotation rateContribution = (rate == 0.0) ? Rotation.IDENTITY
            : new Rotation(rotationRate, -rate * dt);

    // append rotation and rate contribution
    final AngularCoordinates linearPart = new AngularCoordinates(rateContribution.applyTo(rotation),
            rotationRate);

    final double acc = rotationAcceleration.getNorm();
    if (acc == 0.0) {
        // no acceleration, the linear part is sufficient
        return linearPart;
    }

    // compute the quadratic contribution, ignoring initial rotation and rotation rate
    // BEWARE: there is really a minus sign here, because if
    // the target frame rotates in one direction, the vectors in the origin
    // frame seem to rotate in the opposite direction
    final AngularCoordinates quadraticContribution = new AngularCoordinates(
            new Rotation(rotationAcceleration, -0.5 * acc * dt * dt), new Vector3D(dt, rotationAcceleration),
            rotationAcceleration);

    // the quadratic contribution is a small rotation:
    // its initial angle and angular rate are both zero.
    // small rotations are almost commutative, so we append the small
    // quadratic part after the linear part as a simple offset
    return quadraticContribution.addOffset(linearPart);

}

From source file:sceneGraph.AbstractAxes.java

public void rotateTo(Rotation rotation) {
    this.updateGlobal();
    Vector3D xHeading = x().heading().toVector3D();
    Vector3D yHeading = y().heading().toVector3D();
    Vector3D zHeading = z().heading().toVector3D();

    xHeading = rotation.applyTo(xHeading);
    yHeading = rotation.applyTo(yHeading);
    zHeading = rotation.applyTo(zHeading);

    AbstractAxes rotated = instantiate(this.origin(), new DVector(xHeading), new DVector(yHeading),
            new DVector(zHeading));
    if (this.parent != null)
        rotated = parent.getLocalOf(rotated);
    alignLocalsTo(rotated);//from w  w  w.  ja  v  a2  s  . c  o m
}