List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Rotation getAngles
public double[] getAngles(RotationOrder order) throws CardanEulerSingularityException
From source file:nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.MCEntityTransform.java
@Override public void setRotation(Rotation rotation) { double[] euler = rotation.getAngles(RotationUtil.DEFAULT_ORDER); wrapper.rotationYaw = (float) Math.toDegrees(euler[0]); wrapper.rotationPitch = (float) Math.toDegrees(euler[1]); }
From source file:org.orekit.attitudes.LofOffsetTest.java
/** Test if the lof offset is the one expected */// ww w. j av a 2 s . c o m @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 *///from w w w. j a va 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); }