Example usage for org.apache.commons.math3.geometry.euclidean.threed RotationOrder ZYX

List of usage examples for org.apache.commons.math3.geometry.euclidean.threed RotationOrder ZYX

Introduction

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

Prototype

RotationOrder ZYX

To view the source code for org.apache.commons.math3.geometry.euclidean.threed RotationOrder ZYX.

Click Source Link

Document

Set of Cardan angles.

Usage

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

/** Test if the lof offset is the one expected
 *///from  w  w  w .  j a  v  a  2s .  c  om
@Test
public void testOffset() throws OrekitException, CardanEulerSingularityException {

    //  Satellite position
    final CircularOrbit circ = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(0.),
            FastMath.toRadians(270.), FastMath.toRadians(5.300), PositionAngle.MEAN, FramesFactory.getEME2000(),
            date, mu);

    // Create target pointing attitude provider
    // ************************************
    // Elliptic earth shape
    final OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf);
    final GeodeticPoint geoTargetITRF2005 = new GeodeticPoint(FastMath.toRadians(43.36),
            FastMath.toRadians(1.26), 600.);

    // Attitude law definition from geodetic point target
    final TargetPointing targetLaw = new TargetPointing(circ.getFrame(), geoTargetITRF2005, earthShape);
    final Rotation targetRot = targetLaw.getAttitude(circ, date, circ.getFrame()).getRotation();

    // Create lof aligned attitude provider
    // *******************************
    final LofOffset lofAlignedLaw = new LofOffset(orbit.getFrame(), LOFType.VVLH);
    final Rotation lofAlignedRot = lofAlignedLaw.getAttitude(circ, date, circ.getFrame()).getRotation();

    // Get rotation from LOF to target pointing attitude
    Rotation rollPitchYaw = targetRot.applyTo(lofAlignedRot.revert()).revert();
    final double[] angles = rollPitchYaw.getAngles(RotationOrder.ZYX);
    final double yaw = angles[0];
    final double pitch = angles[1];
    final double roll = angles[2];

    // Create lof offset attitude provider with computed roll, pitch, yaw
    // **************************************************************
    final LofOffset lofOffsetLaw = new LofOffset(orbit.getFrame(), LOFType.VVLH, RotationOrder.ZYX, yaw, pitch,
            roll);
    final Rotation lofOffsetRot = lofOffsetLaw.getAttitude(circ, date, circ.getFrame()).getRotation();

    // Compose rotations : target pointing attitudes
    final double angleCompo = targetRot.applyInverseTo(lofOffsetRot).getAngle();
    Assert.assertEquals(0., angleCompo, Utils.epsilonAngle);

}

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

/** Test is the target pointed is the one expected
 *//* www  .  j a  v a  2s  .c  o  m*/
@Test
public void testTarget() throws OrekitException, CardanEulerSingularityException {

    // Create target point and target pointing law towards that point
    final GeodeticPoint targetDef = new GeodeticPoint(FastMath.toRadians(5.), FastMath.toRadians(-40.), 0.);
    final TargetPointing targetLaw = new TargetPointing(orbit.getFrame(), targetDef, earthSpheric);

    // Get roll, pitch, yaw angles corresponding to this pointing law
    final LofOffset lofAlignedLaw = new LofOffset(orbit.getFrame(), LOFType.VVLH);
    final Rotation lofAlignedRot = lofAlignedLaw.getAttitude(orbit, date, orbit.getFrame()).getRotation();
    final Attitude targetAttitude = targetLaw.getAttitude(orbit, date, orbit.getFrame());
    final Rotation rollPitchYaw = targetAttitude.getRotation().applyTo(lofAlignedRot.revert()).revert();
    final double[] angles = rollPitchYaw.getAngles(RotationOrder.ZYX);
    final double yaw = angles[0];
    final double pitch = angles[1];
    final double roll = angles[2];

    // Create a lof offset law from those values
    final LofOffset lofOffsetLaw = new LofOffset(orbit.getFrame(), LOFType.VVLH, RotationOrder.ZYX, yaw, pitch,
            roll);
    final LofOffsetPointing lofOffsetPtLaw = new LofOffsetPointing(orbit.getFrame(), earthSpheric, lofOffsetLaw,
            Vector3D.PLUS_K);

    // Check target pointed by this law : shall be the same as defined
    final Vector3D pTargetRes = lofOffsetPtLaw.getTargetPV(orbit, date, earthSpheric.getBodyFrame())
            .getPosition();
    final GeodeticPoint targetRes = earthSpheric.transform(pTargetRes, earthSpheric.getBodyFrame(), date);

    Assert.assertEquals(targetDef.getLongitude(), targetRes.getLongitude(), Utils.epsilonAngle);
    Assert.assertEquals(targetDef.getLongitude(), targetRes.getLongitude(), Utils.epsilonAngle);

}