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

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

Introduction

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

Prototype

public Rotation applyInverseTo(Rotation r) 

Source Link

Document

Apply the inverse of the instance to another rotation.

Usage

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

/** Test if defined target belongs to the direction pointed by the satellite
 *//*from   ww  w  . ja v  a2s  . co  m*/
@Test
public void testTargetInPointingDirection() throws OrekitException {

    // Create computation date
    AbsoluteDate date = new AbsoluteDate(new DateComponents(2008, 04, 07), TimeComponents.H00,
            TimeScalesFactory.getUTC());

    // Reference frame = ITRF 2005
    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);

    // Elliptic earth shape
    OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf);

    // Create target pointing attitude provider
    GeodeticPoint geoTarget = new GeodeticPoint(FastMath.toRadians(43.36), FastMath.toRadians(1.26), 600.);
    TargetPointing targetAttitudeLaw = new TargetPointing(FramesFactory.getEME2000(), geoTarget, earthShape);

    //  Satellite position
    // ********************
    // Create satellite position as circular parameters
    CircularOrbit circ = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.),
            FastMath.toRadians(270.), FastMath.toRadians(5.300), PositionAngle.MEAN, FramesFactory.getEME2000(),
            date, mu);

    // Transform satellite position to position/velocity parameters in EME2000 frame
    PVCoordinates pvSatEME2000 = circ.getPVCoordinates();

    //  Pointing direction
    // ********************
    // Get satellite attitude rotation, i.e rotation from EME2000 frame to satellite frame
    Rotation rotSatEME2000 = targetAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();

    // Transform Z axis from satellite frame to EME2000
    Vector3D zSatEME2000 = rotSatEME2000.applyInverseTo(Vector3D.PLUS_K);

    // Line containing satellite point and following pointing direction
    Vector3D p = eme2000ToItrf.transformPosition(pvSatEME2000.getPosition());
    Line pointingLine = new Line(p,
            p.add(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, eme2000ToItrf.transformVector(zSatEME2000)),
            1.0e-10);

    // Check that the line contains earth center
    double distance = pointingLine.distance(earthShape.transform(geoTarget));

    Assert.assertEquals(0, distance, 1.e-7);
}

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

/** Test the difference between pointing over two longitudes separated by 5
 *//*  w ww.j  ava2  s .  c o m*/
@Test
public void testSlewedTarget() throws OrekitException {

    // Spheric earth shape
    OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 0., itrf);

    //  Satellite position
    // ********************
    // Create satellite position as circular parameters
    CircularOrbit circ = new CircularOrbit(42164000.0, 0.5e-8, -0.5e-8, 0., 0., FastMath.toRadians(5.300),
            PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);

    // Create nadir pointing attitude provider
    // **********************************
    NadirPointing nadirAttitudeLaw = new NadirPointing(circ.getFrame(), earthShape);

    // Get observed ground point from nadir pointing law
    Vector3D pNadirObservedEME2000 = nadirAttitudeLaw.getTargetPV(circ, date, FramesFactory.getEME2000())
            .getPosition();
    Vector3D pNadirObservedITRF2005 = eme2000ToItrf.transformPosition(pNadirObservedEME2000);

    GeodeticPoint geoNadirObserved = earthShape.transform(pNadirObservedITRF2005, itrf, date);

    // Create target pointing attitude provider with target equal to nadir target
    // *********************************************************************
    TargetPointing targetLawRef = new TargetPointing(circ.getFrame(), itrf, pNadirObservedITRF2005);

    // Get attitude rotation in EME2000
    Rotation rotSatRefEME2000 = targetLawRef.getAttitude(circ, date, circ.getFrame()).getRotation();

    // Create target pointing attitude provider with target 5 from nadir target
    // ********************************************************************
    GeodeticPoint geoTarget = new GeodeticPoint(geoNadirObserved.getLatitude(),
            geoNadirObserved.getLongitude() - FastMath.toRadians(5), geoNadirObserved.getAltitude());
    Vector3D pTargetITRF2005C = earthShape.transform(geoTarget);
    TargetPointing targetLaw = new TargetPointing(circ.getFrame(), itrf, pTargetITRF2005C);

    // Get attitude rotation
    Rotation rotSatEME2000 = targetLaw.getAttitude(circ, date, circ.getFrame()).getRotation();

    // Compute difference between both attitude providers
    // *********************************************
    // Difference between attitudes
    //  expected
    double tanDeltaExpected = (6378136.460 / (42164000.0 - 6378136.460)) * FastMath.tan(FastMath.toRadians(5));
    double deltaExpected = FastMath.atan(tanDeltaExpected);

    //  real
    double deltaReal = rotSatEME2000.applyInverseTo(rotSatRefEME2000).getAngle();

    Assert.assertEquals(deltaReal, deltaExpected, 1.e-4);

}

From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java

/** {@inheritDoc} */
public Vector3D radiationPressureAcceleration(final AbsoluteDate date, final Frame frame,
        final Vector3D position, final Rotation rotation, final double mass, final Vector3D flux)
        throws OrekitException {

    if (flux.getNormSq() < Precision.SAFE_MIN) {
        // null illumination (we are probably in umbra)
        return Vector3D.ZERO;
    }//from  www  .  j  av a  2s  . c  o m

    // radiation flux in spacecraft frame
    final Vector3D fluxSat = rotation.applyTo(flux);

    // solar array contribution
    Vector3D normal = getNormal(date, frame, position, rotation);
    double dot = Vector3D.dotProduct(normal, fluxSat);
    if (dot > 0) {
        // the solar array is illuminated backward,
        // fix signs to compute contribution correctly
        dot = -dot;
        normal = normal.negate();
    }
    Vector3D force = facetRadiationAcceleration(normal, solarArrayArea, fluxSat, dot);

    // body facets contribution
    for (final Facet bodyFacet : facets) {
        normal = bodyFacet.getNormal();
        dot = Vector3D.dotProduct(normal, fluxSat);
        if (dot < 0) {
            // the facet intercepts the incoming flux
            force = force.add(facetRadiationAcceleration(normal, bodyFacet.getArea(), fluxSat, dot));
        }
    }

    // convert to inertial frame
    return rotation.applyInverseTo(new Vector3D(1.0 / mass, force));

}

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

/** Compute a composite translation.
 * @param first first applied transform/*from  ww w. jav a2 s.  c o m*/
 * @param second second applied transform
 * @return translation part of the composite transform
 */
private static Vector3D compositeTranslation(final Transform first, final Transform second) {

    final Vector3D p1 = first.cartesian.getPosition();
    final Rotation r1 = first.angular.getRotation();
    final Vector3D p2 = second.cartesian.getPosition();

    return p1.add(r1.applyInverseTo(p2));

}

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

/** Compute a composite velocity.
 * @param first first applied transform//from   w w w  .j  av  a2  s .co m
 * @param second second applied transform
 * @return velocity part of the composite transform
 */
private static Vector3D compositeVelocity(final Transform first, final Transform second) {

    final Vector3D v1 = first.cartesian.getVelocity();
    final Rotation r1 = first.angular.getRotation();
    final Vector3D o1 = first.angular.getRotationRate();
    final Vector3D p2 = second.cartesian.getPosition();
    final Vector3D v2 = second.cartesian.getVelocity();

    final Vector3D crossP = Vector3D.crossProduct(o1, p2);

    return v1.add(r1.applyInverseTo(v2.add(crossP)));

}

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

/** Compute a composite acceleration.
 * @param first first applied transform/* w w w.j av a2s  .  co m*/
 * @param second second applied transform
 * @return acceleration part of the composite transform
 */
private static Vector3D compositeAcceleration(final Transform first, final Transform second) {

    final Vector3D a1 = first.cartesian.getAcceleration();
    final Rotation r1 = first.angular.getRotation();
    final Vector3D o1 = first.angular.getRotationRate();
    final Vector3D oDot1 = first.angular.getRotationAcceleration();
    final Vector3D p2 = second.cartesian.getPosition();
    final Vector3D v2 = second.cartesian.getVelocity();
    final Vector3D a2 = second.cartesian.getAcceleration();

    final Vector3D crossCrossP = Vector3D.crossProduct(o1, Vector3D.crossProduct(o1, p2));
    final Vector3D crossV = Vector3D.crossProduct(o1, v2);
    final Vector3D crossDotP = Vector3D.crossProduct(oDot1, p2);

    return a1.add(r1.applyInverseTo(new Vector3D(1, a2, 2, crossV, 1, crossCrossP, 1, crossDotP)));

}