List of usage examples for org.apache.commons.math3.complex Quaternion getScalarPart
public double getScalarPart()
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);// w w w . j a v a 2s .com 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()); }