Package cz.fidentis.analyst.math
Class Quaternion
java.lang.Object
javax.vecmath.Tuple4d
javax.vecmath.Quat4d
cz.fidentis.analyst.math.Quaternion
- All Implemented Interfaces:
Serializable
,Cloneable
public final class Quaternion
extends javax.vecmath.Quat4d
This class represents ICP rotation in the form of a quaternion.
Primary, it fixes the error (?) in the
Quat4d
constructor, which normalizes
the given coordinates for some reason. Moreover, this extension
introduces useful methods that accelerate the ICP calculation a bit.- See Also:
-
Field Summary
Fields inherited from class javax.vecmath.Tuple4d
w, x, y, z
-
Constructor Summary
ConstructorsConstructorDescriptionQuaternion
(double x, double y, double z, double w) Builds a quaternion from its components.Builds a quaternion from eigenvalue decomposition. -
Method Summary
Modifier and TypeMethodDescriptionReturns the conjugate quaternion of the instance.static Quaternion
multiply
(Quaternion q1, Quaternion q2) Returns the Hamilton product of two quaternions.javax.vecmath.Matrix4d
toMatrix()
Convert a Quaternion to a rotation matrix.Methods inherited from class javax.vecmath.Quat4d
conjugate, conjugate, interpolate, interpolate, inverse, inverse, mul, mul, mulInverse, mulInverse, normalize, normalize, set, set, set, set, set, set
Methods inherited from class javax.vecmath.Tuple4d
absolute, absolute, add, add, clamp, clamp, clamp, clamp, clampMax, clampMax, clampMax, clampMax, clampMin, clampMin, clampMin, clampMin, clone, epsilonEquals, equals, equals, get, get, hashCode, interpolate, interpolate, interpolate, interpolate, negate, negate, scale, scale, scaleAdd, scaleAdd, scaleAdd, set, set, set, set, sub, sub, toString
-
Constructor Details
-
Quaternion
public Quaternion(double x, double y, double z, double w) Builds a quaternion from its components.- Parameters:
x
- First vector component.y
- Second vector component.z
- Third vector component.w
- Scalar component.
-
Quaternion
Builds a quaternion from eigenvalue decomposition.- Parameters:
ev
- eigenvalue decomposition.
-
-
Method Details
-
getConjugate
Returns the conjugate quaternion of the instance. It method is equivalent to calling theQuat4d.conjugate(javax.vecmath.Quat4d)
method, but it is more effective and readable when the origin quaternion has to be preserved.- Returns:
- the conjugate quaternion
-
multiply
Returns the Hamilton product of two quaternions. It is equivalent toq1.mul(q2)
ofQuat4d
. But calling this method it is faster and more readable if the first quaternion has to be preserved (and then cloned first).- Parameters:
q1
- First quaternion.q2
- Second quaternion.- Returns:
- the Hamilton product of two quaternions
-
toMatrix
public javax.vecmath.Matrix4d toMatrix()Convert a Quaternion to a rotation matrix. It is equivalent to but a bit faster than callingnew Matrix4d(quaternion, new Vector3d(0,0,0), 1);
- Returns:
- a rotation matrix (4x4)
-