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.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 ww. j  a v  a2s .c om

    // 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.forces.BoxAndSolarArraySpacecraft.java

/** Get solar array normal in spacecraft frame.
 * @param date current date// www  . j  ava 2  s  .c  o  m
 * @param frame inertial reference frame for state (both orbit and attitude)
 * @param position position of spacecraft in reference frame
 * @param rotation orientation (attitude) of the spacecraft with respect to reference frame
 * @return solar array normal in spacecraft frame
 * @exception OrekitException if sun direction cannot be computed in best lightning
 * configuration
 */
public synchronized Vector3D getNormal(final AbsoluteDate date, final Frame frame, final Vector3D position,
        final Rotation rotation) throws OrekitException {

    if (referenceDate != null) {
        // use a simple rotation at fixed rate
        final double alpha = rotationRate * date.durationFrom(referenceDate);
        return new Vector3D(FastMath.cos(alpha), saX, FastMath.sin(alpha), saY);
    }

    // compute orientation for best lightning
    final Vector3D sunInert = sun.getPVCoordinates(date, frame).getPosition().subtract(position).normalize();
    final Vector3D sunSpacecraft = rotation.applyTo(sunInert);
    final double d = Vector3D.dotProduct(sunSpacecraft, saZ);
    final double f = 1 - d * d;
    if (f < Precision.EPSILON) {
        // extremely rare case: the sun is along solar array rotation axis
        // (there will not be much output power ...)
        // we set up an arbitrary normal
        return saZ.orthogonal();
    }

    final double s = 1.0 / FastMath.sqrt(f);
    return new Vector3D(s, sunSpacecraft, -s * d, saZ);

}

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

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

    // relative velocity in spacecraft frame
    final Vector3D v = rotation.applyTo(relativeVelocity);

    // solar array contribution
    final Vector3D solarArrayFacet = new Vector3D(solarArrayArea, getNormal(date, frame, position, rotation));
    double sv = FastMath.abs(Vector3D.dotProduct(solarArrayFacet, v));

    // body facets contribution
    for (final Facet facet : facets) {
        final double dot = Vector3D.dotProduct(facet.getNormal(), v);
        if (dot < 0) {
            // the facet intercepts the incoming flux
            sv -= facet.getArea() * dot;
        }//w  w  w  .java  2 s. c o  m
    }

    return new Vector3D(sv * density * dragCoeff / (2.0 * mass), relativeVelocity);

}

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

/** {@inheritDoc} */
public FieldVector3D<DerivativeStructure> dragAcceleration(final AbsoluteDate date, final Frame frame,
        final Vector3D position, final Rotation rotation, final double mass, final double density,
        final Vector3D relativeVelocity, final String paramName) throws OrekitException {

    if (!DRAG_COEFFICIENT.equals(paramName)) {
        throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName, DRAG_COEFFICIENT);
    }/*from ww w. j  a va 2 s  .c om*/

    final DerivativeStructure dragCoeffDS = new DerivativeStructure(1, 1, 0, dragCoeff);

    // relative velocity in spacecraft frame
    final Vector3D v = rotation.applyTo(relativeVelocity);

    // solar array contribution
    final Vector3D solarArrayFacet = new Vector3D(solarArrayArea, getNormal(date, frame, position, rotation));
    double sv = FastMath.abs(Vector3D.dotProduct(solarArrayFacet, v));

    // body facets contribution
    for (final Facet facet : facets) {
        final double dot = Vector3D.dotProduct(facet.getNormal(), v);
        if (dot < 0) {
            // the facet intercepts the incoming flux
            sv -= facet.getArea() * dot;
        }
    }

    return new FieldVector3D<DerivativeStructure>(dragCoeffDS.multiply(sv * density / (2.0 * mass)),
            relativeVelocity);

}

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  w  w  w .j a  v  a 2 s.  c  om

    // 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.forces.BoxAndSolarArraySpacecraft.java

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

    if (flux.getNormSq() < Precision.SAFE_MIN) {
        // null illumination (we are probably in umbra)
        final DerivativeStructure zero = new DerivativeStructure(1, 1, 0.0);
        return new FieldVector3D<DerivativeStructure>(zero, zero, zero);
    }//from   w w  w. jav a 2s  .c om

    final DerivativeStructure absorptionCoeffDS;
    final DerivativeStructure specularReflectionCoeffDS;
    if (ABSORPTION_COEFFICIENT.equals(paramName)) {
        absorptionCoeffDS = new DerivativeStructure(1, 1, 0, absorptionCoeff);
        specularReflectionCoeffDS = new DerivativeStructure(1, 1, specularReflectionCoeff);
    } else if (REFLECTION_COEFFICIENT.equals(paramName)) {
        absorptionCoeffDS = new DerivativeStructure(1, 1, absorptionCoeff);
        specularReflectionCoeffDS = new DerivativeStructure(1, 1, 0, specularReflectionCoeff);
    } else {
        throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName,
                ABSORPTION_COEFFICIENT + ", " + REFLECTION_COEFFICIENT);
    }
    final DerivativeStructure diffuseReflectionCoeffDS = absorptionCoeffDS.add(specularReflectionCoeffDS)
            .subtract(1).negate();

    // 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();
    }
    FieldVector3D<DerivativeStructure> force = facetRadiationAcceleration(normal, solarArrayArea, fluxSat, dot,
            specularReflectionCoeffDS, diffuseReflectionCoeffDS);

    // 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,
                    specularReflectionCoeffDS, diffuseReflectionCoeffDS));
        }
    }

    // convert to inertial
    return FieldRotation.applyInverseTo(rotation, new FieldVector3D<DerivativeStructure>(1.0 / mass, force));

}

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

/** Get the transform from TIRF 2000 at specified date.
 * <p>The update considers the pole motion from IERS data.</p>
 * @param date new value of the date//from w  w w  .j a v  a 2s  .c  o  m
 * @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 {

    // offset from J2000 epoch in julian centuries
    final double tts = date.durationFrom(AbsoluteDate.J2000_EPOCH);
    final double ttc = tts / Constants.JULIAN_CENTURY;

    // pole correction parameters
    final PoleCorrection eop = eopHistory.getPoleCorrection(date);

    // elementary rotations due to pole motion in terrestrial frame
    final Rotation r1 = new Rotation(Vector3D.PLUS_I, -eop.getYp());
    final Rotation r2 = new Rotation(Vector3D.PLUS_J, -eop.getXp());
    final Rotation r3 = new Rotation(Vector3D.PLUS_K, S_PRIME_RATE * ttc);

    // complete pole motion in terrestrial frame
    final Rotation wRot = r3.applyTo(r2.applyTo(r1));

    // combined effects
    final Rotation combined = wRot.revert();

    // set up the transform from parent TIRF
    return new Transform(date, combined, Vector3D.ZERO);

}

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

/** Get the transform from an inertial frame defining position-velocity and the local orbital frame.
 * @param date current date/* w ww.  j av  a  2 s . co  m*/
 * @param pv position-velocity of the spacecraft in some inertial frame
 * @return transform from the frame where position-velocity are defined to local orbital frame
 */
public Transform transformFromInertial(final AbsoluteDate date, final PVCoordinates pv) {

    // compute the translation part of the transform
    final Transform translation = new Transform(date, pv.negate());

    // compute the rotation part of the transform
    final Rotation r = rotationFromInertial(pv);
    final Vector3D p = pv.getPosition();
    final Vector3D momentum = pv.getMomentum();
    final Transform rotation = new Transform(date, r, new Vector3D(1.0 / p.getNormSq(), r.applyTo(momentum)));

    return new Transform(date, translation, rotation);

}

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

/** Get the transfrom from parent frame.
 * <p>The update considers the precession effects.</p>
 * @param date new value of the date//from  w w w .  j  av  a  2 s .  c  o m
 * @return transform at the specified date
 */
public Transform getTransform(final AbsoluteDate date) {

    // compute the precession angles phiA, omegaA, chiA
    final double[] angles = precessionFunction.value(date);

    // elementary rotations for precession
    final Rotation r1 = new Rotation(Vector3D.PLUS_K, -angles[2]);
    final Rotation r2 = new Rotation(Vector3D.PLUS_I, angles[1]);
    final Rotation r3 = new Rotation(Vector3D.PLUS_K, angles[0]);

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

    // set up the transform from parent GCRF
    return new Transform(date, precession);

}

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

@Test
public void testEuler1976() throws OrekitException {

    TransformProvider eulerBasedProvider = new TransformProvider() {
        private static final long serialVersionUID = 1L;
        private final PolynomialNutation<DerivativeStructure> zetaA = new PolynomialNutation<DerivativeStructure>(
                0.0, 2306.2181 * Constants.ARC_SECONDS_TO_RADIANS, 0.30188 * Constants.ARC_SECONDS_TO_RADIANS,
                0.017998 * Constants.ARC_SECONDS_TO_RADIANS);
        private final PolynomialNutation<DerivativeStructure> thetaA = new PolynomialNutation<DerivativeStructure>(
                0.0, 2004.3109 * Constants.ARC_SECONDS_TO_RADIANS, -0.42665 * Constants.ARC_SECONDS_TO_RADIANS,
                -0.041833 * Constants.ARC_SECONDS_TO_RADIANS);
        private final PolynomialNutation<DerivativeStructure> zA = new PolynomialNutation<DerivativeStructure>(
                0.0, 2306.2181 * Constants.ARC_SECONDS_TO_RADIANS, 1.09468 * Constants.ARC_SECONDS_TO_RADIANS,
                0.018203 * Constants.ARC_SECONDS_TO_RADIANS);

        public Transform getTransform(AbsoluteDate date) {
            final double tc = IERSConventions.IERS_1996.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  w w  w. j a v  a  2 s . co m*/
    };

    MODProvider modProvider = new MODProvider(IERSConventions.IERS_1996);

    for (double dt = -5 * Constants.JULIAN_YEAR; dt < 5 * Constants.JULIAN_YEAR; dt += 10
            * 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(), 1.01e-11);
    }

}