Example usage for org.apache.commons.math3.complex Quaternion getVectorPart

List of usage examples for org.apache.commons.math3.complex Quaternion getVectorPart

Introduction

In this page you can find the example usage for org.apache.commons.math3.complex Quaternion getVectorPart.

Prototype

public double[] getVectorPart() 

Source Link

Document

Gets the three components of the vector part of the quaternion.

Usage

From source file:etomica.virial.MCMoveClusterRingRegrowOrientation.java

public void rotateVectorV(double angle, IVector axis, IVectorMutable v) {
    double q0 = Math.cos(angle / 2.0);
    double sth2 = Math.sin(angle / 2.0);
    IVectorMutable a1 = space.makeVector();
    a1.E(axis);/*from  w  ww .j a v  a 2s  .  c o m*/
    a1.TE(sth2);
    double q1 = a1.getX(0);
    double q2 = a1.getX(1);
    double q3 = a1.getX(2);
    Quaternion q = new Quaternion(q0, q1, q2, q3);
    Quaternion vec = new Quaternion(0, v.getX(0), v.getX(1), v.getX(2));
    Quaternion w = q.multiply(vec).multiply(q.getConjugate());
    if (Math.abs(w.getScalarPart()) > 1E-10)
        throw new RuntimeException("Quaternion product is not a vector!");
    v.E(w.getVectorPart());
}