Example usage for org.apache.commons.math3.geometry.euclidean.threed FieldRotation FieldRotation

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

Introduction

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

Prototype

public FieldRotation(final FieldVector3D<T> u, final FieldVector3D<T> v) throws MathArithmeticException 

Source Link

Document

Build one of the rotations that transform one vector into another one.

Usage

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

/** Build one of the rotations that transform one pv coordinates into another one.
        /*from  ww  w.ja v  a2 s.c  o  m*/
 * <p>Except for a possible scale factor, if the instance were
 * applied to the vector u it will produce the vector v. There is an
 * infinite number of such rotations, this constructor choose the
 * one with the smallest associated angle (i.e. the one whose axis
 * is orthogonal to the (u, v) plane). If u and v are collinear, an
 * arbitrary rotation axis is chosen.</p>
        
 * @param u origin vector
 * @param v desired image of u by the rotation
 * @exception OrekitException if the vectors components cannot be converted to
 * {@link DerivativeStructure} with proper order
 */
public AngularCoordinates(final PVCoordinates u, final PVCoordinates v) throws OrekitException {
    this(new FieldRotation<DerivativeStructure>(u.toDerivativeStructureVector(2),
            v.toDerivativeStructureVector(2)));
}

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

private FieldRotation<DerivativeStructure> createRotation(FieldVector3D<DerivativeStructure> axis,
        double angle) {
    return new FieldRotation<DerivativeStructure>(axis, new DerivativeStructure(4, 1, angle));
}

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

@Test
public void testInterpolationAroundPI() throws OrekitException {

    List<TimeStampedFieldAngularCoordinates<DerivativeStructure>> sample = new ArrayList<TimeStampedFieldAngularCoordinates<DerivativeStructure>>();

    // add angular coordinates at t0: 179.999 degrees rotation along X axis
    AbsoluteDate t0 = new AbsoluteDate("2012-01-01T00:00:00.000", TimeScalesFactory.getTAI());
    TimeStampedFieldAngularCoordinates<DerivativeStructure> ac0 = new TimeStampedFieldAngularCoordinates<DerivativeStructure>(
            t0,/*  w  w w.  ja v a 2 s .  com*/
            new FieldRotation<DerivativeStructure>(createVector(1, 0, 0, 4),
                    new DerivativeStructure(4, 1, 3, FastMath.toRadians(179.999))),
            createVector(FastMath.toRadians(0), 0, 0, 4), createVector(0, 0, 0, 4));
    sample.add(ac0);

    // add angular coordinates at t1: -179.999 degrees rotation (= 180.001 degrees) along X axis
    AbsoluteDate t1 = new AbsoluteDate("2012-01-01T00:00:02.000", TimeScalesFactory.getTAI());
    TimeStampedFieldAngularCoordinates<DerivativeStructure> ac1 = new TimeStampedFieldAngularCoordinates<DerivativeStructure>(
            t1,
            new FieldRotation<DerivativeStructure>(createVector(1, 0, 0, 4),
                    new DerivativeStructure(4, 1, 3, FastMath.toRadians(-179.999))),
            createVector(FastMath.toRadians(0), 0, 0, 4), createVector(0, 0, 0, 4));
    sample.add(ac1);

    // get interpolated angular coordinates at mid time between t0 and t1
    AbsoluteDate t = new AbsoluteDate("2012-01-01T00:00:01.000", TimeScalesFactory.getTAI());
    TimeStampedFieldAngularCoordinates<DerivativeStructure> interpolated = TimeStampedFieldAngularCoordinates
            .interpolate(t, AngularDerivativesFilter.USE_R, sample);

    Assert.assertEquals(FastMath.toRadians(180), interpolated.getRotation().getAngle().getReal(), 1.0e-12);

}

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

@Test
public void testInterpolationTooSmallSample() throws OrekitException {
    AbsoluteDate date = AbsoluteDate.GALILEO_EPOCH;
    double alpha0 = 0.5 * FastMath.PI;
    double omega = 0.5 * FastMath.PI;
    TimeStampedFieldAngularCoordinates<DerivativeStructure> reference = new TimeStampedFieldAngularCoordinates<DerivativeStructure>(
            date,/*from   www  .ja  v a  2  s  .  c o m*/
            new FieldRotation<DerivativeStructure>(createVector(0, 0, 1, 4),
                    new DerivativeStructure(4, 1, 3, alpha0)),
            createVector(0, 0, -omega, 4), createVector(0, 0, 0, 4));

    List<TimeStampedFieldAngularCoordinates<DerivativeStructure>> sample = new ArrayList<TimeStampedFieldAngularCoordinates<DerivativeStructure>>();
    FieldRotation<DerivativeStructure> r = reference.shiftedBy(0.2).getRotation();
    sample.add(new TimeStampedFieldAngularCoordinates<DerivativeStructure>(date.shiftedBy(0.2), r,
            createVector(0, 0, 0, 4), createVector(0, 0, 0, 4)));

    try {
        TimeStampedFieldAngularCoordinates.interpolate(date.shiftedBy(0.3), AngularDerivativesFilter.USE_R,
                sample);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.NOT_ENOUGH_DATA_FOR_INTERPOLATION, oe.getSpecifier());
        Assert.assertEquals(1, ((Integer) oe.getParts()[0]).intValue());
    }

}