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

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

Introduction

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

Prototype

Rotation IDENTITY

To view the source code for org.apache.commons.math3.geometry.euclidean.threed Rotation IDENTITY.

Click Source Link

Document

Identity rotation.

Usage

From source file:nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.BWRigidBody.java

void updateRotation(double deltaTime) {

    //Integrate angular velocity to angular displacement
    Rotation angularVel = angularVelocity();
    Rotation deltaRotation = RotationUtil.slerp(Rotation.IDENTITY, angularVel, deltaTime);
    entity().transform().setRotation(entity().rotation().applyTo(deltaRotation));

    //Integrate torque to angular velocity
    Vector3D torque = netTorque.scalarMultiply(deltaTime);
    if (!Vector3D.ZERO.equals(torque)) {
        setAngularVelocity(angularVelocity().applyTo(new Rotation(Vector3DUtil.FORWARD, torque)));
    }/*from   ww w.  j  a  v a  2  s .c om*/

    //Clear net torque
    netTorque = Vector3D.ZERO;

    //Apply drag
    Vector3D eulerAngularVel = angularVelocity().applyInverseTo(Vector3DUtil.FORWARD);
    addTorque(eulerAngularVel.negate().scalarMultiply(angularDrag()));
}

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

@Test
public void testBackwardPropagation() throws OrekitException {

    //  Initial state definition : date, orbit
    final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
    final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
    final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
    final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity),
            FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU);

    final AttitudesSequence attitudesSequence = new AttitudesSequence();
    final AttitudeProvider past = new InertialProvider(Rotation.IDENTITY);
    final AttitudeProvider current = new InertialProvider(Rotation.IDENTITY);
    final AttitudeProvider future = new InertialProvider(Rotation.IDENTITY);
    final Handler handler = new Handler(current, past);
    attitudesSequence.addSwitchingCondition(past, current, new DateDetector(initialDate.shiftedBy(-500.0)),
            true, false, 10.0, AngularDerivativesFilter.USE_R, handler);
    attitudesSequence.addSwitchingCondition(current, future, new DateDetector(initialDate.shiftedBy(+500.0)),
            true, false, 10.0, AngularDerivativesFilter.USE_R, null);
    attitudesSequence.resetActiveProvider(current);

    final Propagator propagator = new EcksteinHechlerPropagator(initialOrbit, attitudesSequence,
            Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20,
            Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50,
            Constants.EIGEN5C_EARTH_C60);

    // Register the switching events to the propagator
    attitudesSequence.registerSwitchEvents(propagator);

    SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(-10000.0));
    Assert.assertEquals(1, handler.dates.size());
    Assert.assertEquals(-500.0, handler.dates.get(0).durationFrom(initialDate), 1.0e-3);
    Assert.assertEquals(-490.0, finalState.getDate().durationFrom(initialDate), 1.0e-3);

}

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

@Test
public void testTooShortTransition() {
    double threshold = 1.5;
    double transitionTime = 0.5;
    try {/*w w w .j  av  a  2  s . c  om*/
        new AttitudesSequence().addSwitchingCondition(new InertialProvider(Rotation.IDENTITY),
                new InertialProvider(Rotation.IDENTITY),
                new DateDetector(1000.0, threshold, AbsoluteDate.J2000_EPOCH), true, false, transitionTime,
                AngularDerivativesFilter.USE_R, null);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.TOO_SHORT_TRANSITION_TIME_FOR_ATTITUDES_SWITCH, oe.getSpecifier());
        Assert.assertEquals(transitionTime, ((Double) oe.getParts()[0]).doubleValue(), 1.0e-10);
        Assert.assertEquals(threshold, ((Double) oe.getParts()[1]).doubleValue(), 1.0e-10);
    }
}

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

@Test
public void testShift() throws OrekitException {
    double rate = 2 * FastMath.PI / (12 * 60);
    Attitude attitude = new Attitude(AbsoluteDate.J2000_EPOCH, FramesFactory.getEME2000(), Rotation.IDENTITY,
            new Vector3D(rate, Vector3D.PLUS_K), Vector3D.ZERO);
    Assert.assertEquals(rate, attitude.getSpin().getNorm(), 1.0e-10);
    double dt = 10.0;
    double alpha = rate * dt;
    Attitude shifted = attitude.shiftedBy(dt);
    Assert.assertEquals(rate, shifted.getSpin().getNorm(), 1.0e-10);
    Assert.assertEquals(alpha, Rotation.distance(attitude.getRotation(), shifted.getRotation()), 1.0e-10);

    Vector3D xSat = shifted.getRotation().applyInverseTo(Vector3D.PLUS_I);
    Assert.assertEquals(0.0, xSat.subtract(new Vector3D(FastMath.cos(alpha), FastMath.sin(alpha), 0)).getNorm(),
            1.0e-10);/*  w  ww  . java 2  s  .  co m*/
    Vector3D ySat = shifted.getRotation().applyInverseTo(Vector3D.PLUS_J);
    Assert.assertEquals(0.0,
            ySat.subtract(new Vector3D(-FastMath.sin(alpha), FastMath.cos(alpha), 0)).getNorm(), 1.0e-10);
    Vector3D zSat = shifted.getRotation().applyInverseTo(Vector3D.PLUS_K);
    Assert.assertEquals(0.0, zSat.subtract(Vector3D.PLUS_K).getNorm(), 1.0e-10);

}

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

@Test
public void testSpin() throws OrekitException {

    AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789),
            TimeScalesFactory.getUTC());
    double rate = 2.0 * FastMath.PI / (12 * 60);
    AttitudeProvider law = new SpinStabilized(new InertialProvider(Rotation.IDENTITY), date, Vector3D.PLUS_K,
            rate);// w  w w. j av  a2s. c  o m
    KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.),
            FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN,
            FramesFactory.getEME2000(), date, 3.986004415e14);

    Propagator propagator = new KeplerianPropagator(orbit, law);

    double h = 10.0;
    SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h));
    SpacecraftState s0 = propagator.propagate(date);
    SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h));
    Vector3D spin0 = s0.getAttitude().getSpin();

    // check spin is consistent with attitude evolution
    double errorAngleMinus = Rotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(),
            s0.getAttitude().getRotation());
    double evolutionAngleMinus = Rotation.distance(sMinus.getAttitude().getRotation(),
            s0.getAttitude().getRotation());
    Assert.assertTrue(errorAngleMinus <= 1.0e-6 * evolutionAngleMinus);
    double errorAnglePlus = Rotation.distance(s0.getAttitude().getRotation(),
            sPlus.shiftedBy(-h).getAttitude().getRotation());
    double evolutionAnglePlus = Rotation.distance(s0.getAttitude().getRotation(),
            sPlus.getAttitude().getRotation());
    Assert.assertTrue(errorAnglePlus <= 1.0e-6 * evolutionAnglePlus);

    // compute spin axis using finite differences
    Rotation rM = sMinus.getAttitude().getRotation();
    Rotation rP = sPlus.getAttitude().getRotation();
    Vector3D reference = AngularCoordinates.estimateRate(rM, rP, 2 * h);

    Assert.assertEquals(2 * FastMath.PI / reference.getNorm(), 2 * FastMath.PI / spin0.getNorm(), 0.05);
    Assert.assertEquals(0.0, FastMath.toDegrees(Vector3D.angle(reference, spin0)), 1.0e-10);
    Assert.assertEquals(0.0, FastMath.toDegrees(Vector3D.angle(Vector3D.PLUS_K, spin0)), 1.0e-10);

}

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

/** Compute the transform at some date.
 * @param date date at which the transform is desired
 * @return computed transform at specified date
 *//*from  ww  w. j  a  v  a  2s . c o  m*/
public Transform getTransform(final AbsoluteDate date) {

    // compute parameters evolution since reference epoch
    final double dt = date.durationFrom(epoch);
    final Vector3D dR = new Vector3D(1, rotationVector, dt, rotationRate);

    // build translation part
    final Transform translationTransform = new Transform(date, cartesian.shiftedBy(dt));

    // build rotation part
    final double angle = dR.getNorm();
    final Transform rotationTransform = new Transform(date,
            (angle < Precision.SAFE_MIN) ? Rotation.IDENTITY : new Rotation(dR, angle), rotationRate);

    // combine both parts
    return new Transform(date, translationTransform, rotationTransform);

}

From source file:org.orekit.propagation.SpacecraftStateTest.java

@Test(expected = IllegalArgumentException.class)
public void testFramesConsistency() throws OrekitException {
    new SpacecraftState(orbit, new Attitude(orbit.getDate(), FramesFactory.getGCRF(), Rotation.IDENTITY,
            Vector3D.ZERO, Vector3D.ZERO));
}

From source file:org.orekit.utils.AngularCoordinates.java

/** Simple constructor.
 * <p> Sets the Coordinates to default : Identity,  = (0 0 0), d/dt = (0 0 0).</p>
 *//*from  w  w w.jav a  2  s  . co  m*/
public AngularCoordinates() {
    this(Rotation.IDENTITY, Vector3D.ZERO, Vector3D.ZERO);
}

From source file:org.orekit.utils.AngularCoordinates.java

/** Get a time-shifted state.
 * <p>//from www . j  av  a 2  s. co m
 * The state can be slightly shifted to close dates. This shift is based on
 * an approximate solution of the fixed acceleration motion. It is <em>not</em>
 * intended as a replacement for proper attitude propagation but should be
 * sufficient for either small time shifts or coarse accuracy.
 * </p>
 * @param dt time shift in seconds
 * @return a new state, shifted with respect to the instance (which is immutable)
 */
public AngularCoordinates shiftedBy(final double dt) {

    // the shiftedBy method is based on a local approximation.
    // It considers separately the contribution of the constant
    // rotation, the linear contribution or the rate and the
    // quadratic contribution of the acceleration. The rate
    // and acceleration contributions are small rotations as long
    // as the time shift is small, which is the crux of the algorithm.
    // Small rotations are almost commutative, so we append these small
    // contributions one after the other, as if they really occurred
    // successively, despite this is not what really happens.

    // compute the linear contribution first, ignoring acceleration
    // BEWARE: there is really a minus sign here, because if
    // the target frame rotates in one direction, the vectors in the origin
    // frame seem to rotate in the opposite direction
    final double rate = rotationRate.getNorm();
    final Rotation rateContribution = (rate == 0.0) ? Rotation.IDENTITY
            : new Rotation(rotationRate, -rate * dt);

    // append rotation and rate contribution
    final AngularCoordinates linearPart = new AngularCoordinates(rateContribution.applyTo(rotation),
            rotationRate);

    final double acc = rotationAcceleration.getNorm();
    if (acc == 0.0) {
        // no acceleration, the linear part is sufficient
        return linearPart;
    }

    // compute the quadratic contribution, ignoring initial rotation and rotation rate
    // BEWARE: there is really a minus sign here, because if
    // the target frame rotates in one direction, the vectors in the origin
    // frame seem to rotate in the opposite direction
    final AngularCoordinates quadraticContribution = new AngularCoordinates(
            new Rotation(rotationAcceleration, -0.5 * acc * dt * dt), new Vector3D(dt, rotationAcceleration),
            rotationAcceleration);

    // the quadratic contribution is a small rotation:
    // its initial angle and angular rate are both zero.
    // small rotations are almost commutative, so we append the small
    // quadratic part after the linear part as a simple offset
    return quadraticContribution.addOffset(linearPart);

}

From source file:org.orekit.utils.AngularCoordinatesTest.java

@Test
public void testDefaultConstructor() throws OrekitException {
    AngularCoordinates ac = new AngularCoordinates();
    Assert.assertEquals(0.0, ac.getRotationAcceleration().getNorm(), 1.0e-15);
    Assert.assertEquals(0.0, ac.getRotationRate().getNorm(), 1.0e-15);
    Assert.assertEquals(0.0, Rotation.distance(ac.getRotation(), Rotation.IDENTITY), 1.0e-10);
}