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

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

Introduction

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

Prototype

public Vector3D getAxis() 

Source Link

Document

Get the normalized axis of the rotation.

Usage

From source file:org.orekit.attitudes.YawCompensationTest.java

/** Test that compensation rotation axis is Zsat, yaw axis
 *//*from  w  ww .  j a  v a  2  s.c  o  m*/
@Test
public void testCompensAxis() throws OrekitException {

    //  Attitude laws
    // **************
    // Target pointing attitude provider over satellite nadir at date, without yaw compensation
    NadirPointing nadirLaw = new NadirPointing(circOrbit.getFrame(), earthShape);

    // Target pointing attitude provider with yaw compensation
    YawCompensation yawCompensLaw = new YawCompensation(circOrbit.getFrame(), nadirLaw);

    // Get attitude rotations from non yaw compensated / yaw compensated laws
    Rotation rotNoYaw = nadirLaw.getAttitude(circOrbit, date, circOrbit.getFrame()).getRotation();
    Rotation rotYaw = yawCompensLaw.getAttitude(circOrbit, date, circOrbit.getFrame()).getRotation();

    // Compose rotations composition
    Rotation compoRot = rotYaw.applyTo(rotNoYaw.revert());
    Vector3D yawAxis = compoRot.getAxis();

    // Check axis
    Assert.assertEquals(0., yawAxis.subtract(Vector3D.PLUS_K).getNorm(), Utils.epsilonTest);

}

From source file:org.orekit.attitudes.YawSteeringTest.java

@Test
public void testCompensAxis() throws OrekitException {

    //  Attitude laws
    // **************
    // Target pointing attitude provider over satellite nadir at date, without yaw compensation
    NadirPointing nadirLaw = new NadirPointing(circOrbit.getFrame(), earthShape);

    // Target pointing attitude provider with yaw compensation
    YawSteering yawCompensLaw = new YawSteering(circOrbit.getFrame(), nadirLaw, CelestialBodyFactory.getSun(),
            Vector3D.MINUS_I);/* w  w w.j a v  a 2s. co m*/

    // Get attitude rotations from non yaw compensated / yaw compensated laws
    Rotation rotNoYaw = nadirLaw.getAttitude(circOrbit, date, circOrbit.getFrame()).getRotation();
    Rotation rotYaw = yawCompensLaw.getAttitude(circOrbit, date, circOrbit.getFrame()).getRotation();

    // Compose rotations composition
    Rotation compoRot = rotYaw.applyTo(rotNoYaw.revert());
    Vector3D yawAxis = compoRot.getAxis();

    // Check axis
    Assert.assertEquals(0., yawAxis.getX(), Utils.epsilonTest);
    Assert.assertEquals(0., yawAxis.getY(), Utils.epsilonTest);
    Assert.assertEquals(1., yawAxis.getZ(), Utils.epsilonTest);

}

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

@Test
public void testMSLIBTransformJ2000_TerRef() throws OrekitException {

    AbsoluteDate t0 = new AbsoluteDate(new DateComponents(2003, 10, 14), new TimeComponents(02, 00, 00),
            TimeScalesFactory.getUTC());
    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    Transform trans = FramesFactory.getEME2000().getTransformTo(itrf, t0);

    // Coordinates in EME2000
    PVCoordinates pvEME2000 = new PVCoordinates(new Vector3D(6500000.0, -1234567.0, 4000000.0),
            new Vector3D(3609.28229, 3322.88979, -7083.950661));

    // Reference coordinates in ITRF
    PVCoordinates pvRef = new PVCoordinates(
            new Vector3D(3011113.971820046, -5889827.854375269, 4002158.938875904),
            new Vector3D(4410.393506651586, -1033.61784235127, -7082.633883124906));

    // tests using direct transform
    checkPV(pvRef, trans.transformPVCoordinates(pvEME2000), 0.594, 1.79e-4);

    // compute local evolution using finite differences
    double h = 1.0;
    Rotation r0 = trans.getRotation();/*from www .j ava  2 s . co m*/
    AbsoluteDate date = t0.shiftedBy(-2 * h);
    Rotation evoM2h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert());
    double alphaM2h = -evoM2h.getAngle();
    Vector3D axisM2h = evoM2h.getAxis();
    date = t0.shiftedBy(-h);
    Rotation evoM1h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert());
    double alphaM1h = -evoM1h.getAngle();
    Vector3D axisM1h = evoM1h.getAxis();
    date = t0.shiftedBy(h);
    Rotation evoP1h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert());
    double alphaP1h = evoP1h.getAngle();
    Vector3D axisP1h = evoP1h.getAxis().negate();
    date = t0.shiftedBy(2 * h);
    Rotation evoP2h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert());
    double alphaP2h = evoP2h.getAngle();
    Vector3D axisP2h = evoP2h.getAxis().negate();
    double w = (8 * (alphaP1h - alphaM1h) - (alphaP2h - alphaM2h)) / (12 * h);
    Vector3D axis = axisM2h.add(axisM1h).add(axisP1h.add(axisP2h)).normalize();
    Transform finiteDiffTransform = new Transform(t0, trans.getRotation(), new Vector3D(w, axis));

    checkPV(pvRef, finiteDiffTransform.transformPVCoordinates(pvEME2000), 0.594, 1.78e-4);

}

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

@Test
public void testRotPV() {

    RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l);

    // Instant Rotation only

    for (int i = 0; i < 10; ++i) {

        // Random instant rotation

        Rotation instantRot = randomRotation(rnd);
        Vector3D normAxis = instantRot.getAxis();
        double w = FastMath.abs(instantRot.getAngle()) / Constants.JULIAN_DAY;

        // random rotation
        Rotation rot = randomRotation(rnd);

        // so we have a transform
        Transform tr = new Transform(AbsoluteDate.J2000_EPOCH, rot, new Vector3D(w, normAxis));

        // random position, velocity, acceleration
        Vector3D pos = randomVector(1.0e3, rnd);
        Vector3D vel = randomVector(1.0, rnd);
        Vector3D acc = randomVector(1.0e-3, rnd);

        PVCoordinates pvOne = new PVCoordinates(pos, vel, acc);

        // we obtain

        PVCoordinates pvTwo = tr.transformPVCoordinates(pvOne);

        // test inverse

        Vector3D resultvel = tr.getInverse().transformPVCoordinates(pvTwo).getVelocity();

        checkVector(resultvel, vel, 1.0e-15);

    }// w  ww .  j  a v a 2s.c o m

}

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

@Test
public void testRotation() {
    RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l);
    for (int i = 0; i < 10; ++i) {

        Rotation r = randomRotation(rnd);
        Vector3D axis = r.getAxis();
        double angle = r.getAngle();

        Transform transform = new Transform(AbsoluteDate.J2000_EPOCH, r);
        for (int j = 0; j < 10; ++j) {
            Vector3D a = new Vector3D(rnd.nextDouble(), rnd.nextDouble(), rnd.nextDouble());
            Vector3D b = transform.transformVector(a);
            Assert.assertEquals(Vector3D.angle(axis, a), Vector3D.angle(axis, b), 1.0e-14);
            Vector3D aOrtho = Vector3D.crossProduct(axis, a);
            Vector3D bOrtho = Vector3D.crossProduct(axis, b);
            Assert.assertEquals(angle, Vector3D.angle(aOrtho, bOrtho), 1.0e-14);
            Vector3D c = transform.transformPosition(a);
            Assert.assertEquals(0, c.subtract(b).getNorm(), 1.0e-14);
        }// ww  w  .  ja v a 2  s. co  m

    }
}

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//from w  ww  .  ja  v  a 2s .  co  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());
}