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

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

Introduction

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

Prototype

public T getQ0() 

Source Link

Document

Get the scalar coordinate of the quaternion.

Usage

From source file:org.orekit.propagation.numerical.Jacobianizer.java

/** Shift a rotation.
 * @param nominal nominal rotation//  ww w. j a  va 2  s  . c  om
 * @param index index of the variable with respect to which we shift
 * @param h shift step
 * @return shifted rotation
 */
private Rotation shift(final FieldRotation<DerivativeStructure> nominal, final int index, final double h) {
    final double[] delta = new double[nominal.getQ0().getFreeParameters()];
    delta[index] = h;
    return new Rotation(nominal.getQ0().taylor(delta), nominal.getQ1().taylor(delta),
            nominal.getQ2().taylor(delta), nominal.getQ3().taylor(delta), true);
}

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

/** Builds a AngularCoordinates from  a {@link FieldRotation}&lt;{@link DerivativeStructure}&gt;.
 * <p>//from   ww w .  j  ava  2  s .  co m
 * The rotation components must have time as their only derivation parameter and
 * have consistent derivation orders.
 * </p>
 * @param r rotation with time-derivatives embedded within the coordinates
 */
public AngularCoordinates(final FieldRotation<DerivativeStructure> r) {

    final double q0 = r.getQ0().getReal();
    final double q1 = r.getQ1().getReal();
    final double q2 = r.getQ2().getReal();
    final double q3 = r.getQ3().getReal();

    rotation = new Rotation(q0, q1, q2, q3, false);
    if (r.getQ0().getOrder() >= 1) {
        final double q0Dot = r.getQ0().getPartialDerivative(1);
        final double q1Dot = r.getQ1().getPartialDerivative(1);
        final double q2Dot = r.getQ2().getPartialDerivative(1);
        final double q3Dot = r.getQ3().getPartialDerivative(1);
        rotationRate = new Vector3D(
                2 * MathArrays.linearCombination(-q1, q0Dot, q0, q1Dot, q3, q2Dot, -q2, q3Dot),
                2 * MathArrays.linearCombination(-q2, q0Dot, -q3, q1Dot, q0, q2Dot, q1, q3Dot),
                2 * MathArrays.linearCombination(-q3, q0Dot, q2, q1Dot, -q1, q2Dot, q0, q3Dot));
        if (r.getQ0().getOrder() >= 2) {
            final double q0DotDot = r.getQ0().getPartialDerivative(2);
            final double q1DotDot = r.getQ1().getPartialDerivative(2);
            final double q2DotDot = r.getQ2().getPartialDerivative(2);
            final double q3DotDot = r.getQ3().getPartialDerivative(2);
            rotationAcceleration = new Vector3D(
                    2 * MathArrays.linearCombination(-q1, q0DotDot, q0, q1DotDot, q3, q2DotDot, -q2, q3DotDot),
                    2 * MathArrays.linearCombination(-q2, q0DotDot, -q3, q1DotDot, q0, q2DotDot, q1, q3DotDot),
                    2 * MathArrays.linearCombination(-q3, q0DotDot, q2, q1DotDot, -q1, q2DotDot, q0, q3DotDot));
        } else {
            rotationAcceleration = Vector3D.ZERO;
        }
    } else {
        rotationRate = Vector3D.ZERO;
        rotationAcceleration = Vector3D.ZERO;
    }

}

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

/** Builds a rotation/rotation rate pair.
 * @param rotation rotation//from   ww w. j ava  2  s .com
 * @param rotationRate rotation rate  (rad/s)
 */
public FieldAngularCoordinates(final FieldRotation<T> rotation, final FieldVector3D<T> rotationRate) {
    this(rotation, rotationRate, new FieldVector3D<T>(rotation.getQ0().getField().getZero(),
            rotation.getQ0().getField().getZero(), rotation.getQ0().getField().getZero()));
}