public class PamQuaternion
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Wikipedia Description 15/11/2013
Unit quaternions, also known as versors, provide a convenient mathematical notation for representing orientations and rotations of objects in three dimensions. Compared to Euler angles they are simpler to compose and avoid the problem of gimbal lock. Compared to rotation matrices they are more numerically stable and may be more efficient. Quaternions have found their way into applications in computer graphics, computer vision, robotics, navigation, molecular dynamics, flight dynamics,[1] and orbital mechanics of satellites
Code is heavily based on code from Prasanna Velagapudi. Copyright (c) 2008, Prasanna Velagapudi
Note this code is also available in the apache common 3+ library. PAMGUARD currently implements the Apache 2.2 library so have made unique class.
Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID
Determines if a de-serialized object is compatible with this class.
|
static double |
SINGULARITY_NORTH_POLE
This defines the north pole singularity cutoff when converting
from quaternions to Euler angles.
|
static double |
SINGULARITY_SOUTH_POLE
This defines the south pole singularity cutoff when converting
from quaternions to Euler angles.
|
Constructor and Description |
---|
PamQuaternion(double[] q)
Wrap a quaternion in vector form.
|
PamQuaternion(double heading,
double pitch,
double roll)
Create a quartenion from euler angles.
|
PamQuaternion(double w,
double x,
double y,
double z)
Construct a new quaternion.
|
Modifier and Type | Method and Description |
---|---|
PamQuaternion |
clone() |
static double[] |
fromEulerAngles(double heading,
double pitch,
double roll)
Create a quaternion from euler angles.
|
static PamQuaternion |
fromRotation(Jama.Matrix m) |
static PamQuaternion |
fromTransform(Jama.Matrix t) |
double[] |
getArray()
Access the components of the quaternion.
|
double |
getW()
Access the w-component (scalar) of the quaternion.
|
double |
getX()
Access the x-component ("i") of the quaternion.
|
double |
getY()
Access the y-component ("j") of the quaternion.
|
double |
getZ()
Access the z-component ("k") of the quaternion.
|
double[] |
toEulerAngles()
Returns the components of the quaternion if it is represented
as standard roll-pitch-yaw Euler angles.
|
double |
toHeading()
Returns the yaw component of the quaternion if it is represented
as standard roll-pitch-yaw Euler angles.
|
double |
toPitch()
Returns the roll component of the quaternion if it is represented
as standard roll-pitch-yaw Euler angles.
|
double |
toRoll()
Returns the pitch component of the quaternion if it is represented
as standard roll-pitch-yaw Euler angles.
|
Jama.Matrix |
toRotation()
Converts quaternion to (3x3) rotation matrix.
|
java.lang.String |
toString() |
Jama.Matrix |
toTransform() |
public static final long serialVersionUID
public static final double SINGULARITY_NORTH_POLE
public static final double SINGULARITY_SOUTH_POLE
public PamQuaternion(double w, double x, double y, double z)
w
- the w-coordinate of the objectx
- the x-coordinate of the objecty
- the y-coordinate of the objectz
- the z-coordinate of the objectpublic PamQuaternion(double[] q)
q
- a quaternion vector in {w, x, y, z} form.public PamQuaternion(double heading, double pitch, double roll)
eulerAnlges-
- these are the euler angles in RADIANS.public double getW()
public double getX()
public double getY()
public double getZ()
public double[] getArray()
public static PamQuaternion fromRotation(Jama.Matrix m)
public Jama.Matrix toRotation()
public static PamQuaternion fromTransform(Jama.Matrix t)
public Jama.Matrix toTransform()
public static double[] fromEulerAngles(double heading, double pitch, double roll)
heading-
- 0-360 degrees. Input in RADIANSpitch
- - 90->90 degreens. Input in RADIANSroll
- -0->180 and 0->-180.public double toPitch()
public double toRoll()
public double toHeading()
public double[] toEulerAngles()
public PamQuaternion clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object