public class UnitQuaternions extends Object
Quat4d
Class from
vecmath to represent the unit quaternions, and it also implements some of the
basic methods that the library is missing.
A Unit Quaternion is a four-dimensional vector used to describe a three-dimensional attitude representation (axis and angle of rotation). By definition, unit quaternions are always normalized, so their length is always 1.
Modifier and Type | Method and Description |
---|---|
static double |
angle(javax.vecmath.Quat4d q)
Calculate the rotation angle component of the input unit quaternion.
|
static double |
dotProduct(javax.vecmath.Quat4d q1,
javax.vecmath.Quat4d q2)
Compute the dot (inner) product of two quaternions.
|
static javax.vecmath.Quat4d |
orientation(javax.vecmath.Point3d[] points)
The orientation represents the rotation of the principal axes with
respect to the axes of the coordinate system (unit vectors [1,0,0],
[0,1,0] and [0,0,1]).
|
static double |
orientationAngle(javax.vecmath.Point3d[] fixed,
javax.vecmath.Point3d[] moved)
The angle of the relative orientation of the two sets of points in 3D.
|
static double |
orientationAngle(javax.vecmath.Point3d[] fixed,
javax.vecmath.Point3d[] moved,
boolean centered)
The angle of the relative orientation of the two sets of points in 3D.
|
static double |
orientationMetric(javax.vecmath.Point3d[] a,
javax.vecmath.Point3d[] b)
The orientation metric is obtained by comparing the quaternion
orientations of the principal axes of each set of points in 3D.
|
static double |
orientationMetric(javax.vecmath.Quat4d q1,
javax.vecmath.Quat4d q2)
The orientation metric is obtained by comparing two unit quaternion
orientations.
|
static javax.vecmath.Quat4d |
relativeOrientation(javax.vecmath.Point3d[] fixed,
javax.vecmath.Point3d[] moved)
Calculate the relative quaternion orientation of two arrays of points.
|
public static double orientationMetric(javax.vecmath.Point3d[] a, javax.vecmath.Point3d[] b)
First, the quaternion orientation of each set of points is calculated
using their principal axes with orientation(Point3d[])
. Then,
the two quaternions are compared using the method
orientationMetric(Quat4d, Quat4d)
.
A requisite for this method to work properly is that both sets of points
have to define the same shape (or very low RMSD), otherwise some of the
principal axes might change or be inverted, resulting in an unreliable
metric. For shapes with some deviations in their shape, use the metric
orientationAngle(Point3d[], Point3d[])
.
a
- array of Point3db
- array of Point3dpublic static double orientationMetric(javax.vecmath.Quat4d q1, javax.vecmath.Quat4d q2)
The two quaternions are compared using the formula: d(q1,q2) = arccos(|q1*q2|). The range of the metric is [0, Pi/2], where 0 means the same orientation and Pi/2 means the opposite orientation.
The formula is taken from: Huynh, D. Q. (2009). Metrics for 3D rotations: comparison and analysis. Journal of Mathematical Imaging and Vision, 35(2), 155–164. http://doi.org/10.1007/s10851-009-0161-2
q1
- quaternion as Quat4d objectq2
- quaternion as Quat4d objectpublic static javax.vecmath.Quat4d orientation(javax.vecmath.Point3d[] points)
The orientation can be expressed as a unit quaternion.
points
- array of Point3dpublic static double angle(javax.vecmath.Quat4d q)
q
- unit quaternion Quat4dpublic static double orientationAngle(javax.vecmath.Point3d[] fixed, javax.vecmath.Point3d[] moved)
angle(Quat4d)
of the unit quaternion obtained by
relativeOrientation(Point3d[], Point3d[])
.
The arrays of points need to be centered at the origin. To center the
points use CalcPoint.center(Point3d[])
.
fixed
- array of Point3d, centered at origin. Original coordinates
will not be modified.moved
- array of Point3d, centered at origin. Original coordinates
will not be modified.public static double orientationAngle(javax.vecmath.Point3d[] fixed, javax.vecmath.Point3d[] moved, boolean centered)
angle(Quat4d)
of the unit quaternion obtained by
relativeOrientation(Point3d[], Point3d[])
.fixed
- array of Point3d. Original coordinates will not be modified.moved
- array of Point3d. Original coordinates will not be modified.centered
- true if the points are already centered at the originpublic static javax.vecmath.Quat4d relativeOrientation(javax.vecmath.Point3d[] fixed, javax.vecmath.Point3d[] moved)
fixed
- point array, coordinates will not be modifiedmoved
- point array, coordinates will not be modifiedpublic static double dotProduct(javax.vecmath.Quat4d q1, javax.vecmath.Quat4d q2)
q1
- quaternion as Quat4d objectq2
- quaternion as Quat4d objectCopyright © 2000–2018 BioJava. All rights reserved.