|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.numerics.Quaternion
public class Quaternion
Quaterion models a unit quaternion and implements quaternion arithmetic.
Nested Class Summary | |
---|---|
protected static class |
Quaternion.QuaternionLoader
|
Constructor Summary | |
---|---|
Quaternion()
Constructs and initializes a unit quaternion (1,0,0,0). |
|
Quaternion(double[] q)
Constructs and initializes a quaternion from the array of length 4. |
|
Quaternion(double q0,
double q1,
double q2,
double q3)
Constructs and initializes quaternion from the specified components. |
|
Quaternion(double q0,
Vec3D vector)
Constructs and initializes quaternion from the specified components. |
|
Quaternion(Quaternion q)
Constructs and initializes a Quaternion with the same values as the given quaternion. |
Method Summary | |
---|---|
void |
add(Quaternion q)
Adds this quaternion to the given quaternion. |
double |
angle(Quaternion q)
Returns the angle in radians between this quaternion and the given quaternion. |
java.lang.Object |
clone()
Instaniates a quaterion whose components are identical to this quaterion. |
void |
conjugate()
Conjugates this quaternion in place. |
static Quaternion |
createAlignmentTransformation(double[] v1,
double[] v2)
Instantiates a quaternion that aligns the first vector with the second vector. |
double[] |
direct(double[] p)
Transforms (rotates) the coordinates of the given point. |
double |
dot(Quaternion q)
Returns the dot product of this quaternion and quaternion q. |
double[] |
getCoordinates()
Gets the Quaternion coordinates. |
double[] |
getFlatMatrix(double[] mat)
Gets the direct homogeneous affine transformation flattened into a 1-d arrray. |
static XML.ObjectLoader |
getLoader()
|
double[][] |
getRotationMatrix(double[][] mat)
Gets the direct rotation matrix of this quaternion rotation. |
double[] |
inverse(double[] p)
The inverse transformation (if it exists). |
double |
magnitude()
Returns the magnitude of this quaternion. |
double |
magnitudeSquared()
Returns the squared magnitude of this vector. |
void |
multiply(Quaternion q)
Multiplies this quaternion with the given quaternion. |
void |
normalize()
Normalizes this quaternion in place. |
double[] |
setCoordinates(double[] q)
Sets the quaternion coordinates from the array of length 4. |
void |
setCoordinates(double q0,
double q1,
double q2,
double q3)
Sets the quaternion coordinates. |
double[] |
setOrigin(double[] origin)
Sets the origin for this rotation. |
void |
setOrigin(double ox,
double oy,
double oz)
Sets the origin for this rotation. |
void |
subtract(Quaternion q)
Subtracts this quaternion from the given quaternion. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Quaternion(double q0, double q1, double q2, double q3)
q0
- doubleq1
- doubleq2
- doubleq3
- doublepublic Quaternion(double q0, Vec3D vector)
q0
- doublevector
- sets with q1:vector.x, q2:vector.y, q3:vector.zpublic Quaternion(double[] q)
q
- the array of length 4 containing q0, q1, q2, q3public Quaternion(Quaternion q)
q
- the Vector3d containing the initialization x y z datapublic Quaternion()
Method Detail |
---|
public static Quaternion createAlignmentTransformation(double[] v1, double[] v2)
v1
- double[]v2
- double[]
public void setOrigin(double ox, double oy, double oz)
ox
- doubleoy
- doubleoz
- doublepublic double[] setOrigin(double[] origin)
origin
- double[] the new origin
public final double[][] getRotationMatrix(double[][] mat)
mat
- double[][] optional matrix
public final double[] getFlatMatrix(double[] mat)
getFlatMatrix
in interface MatrixTransformation
mat
- double[] optional matrix
public double[] getCoordinates()
public final void setCoordinates(double q0, double q1, double q2, double q3)
q0
- doubleq1
- doubleq2
- doubleq3
- doublepublic final double[] setCoordinates(double[] q)
q
- the array of length 4 containing q0, q1, q2, q3public final void normalize()
public final void conjugate()
public final void add(Quaternion q)
q
- Quaternionpublic final void subtract(Quaternion q)
q
- Quaternionpublic final void multiply(Quaternion q)
q
- Quaternionpublic final double dot(Quaternion q)
q
- the other quaternion
public final double magnitudeSquared()
public final double magnitude()
public final double angle(Quaternion q)
q
- the other quaternion
public java.lang.Object clone()
clone
in interface Transformation
clone
in class java.lang.Object
public double[] direct(double[] p)
direct
in interface Transformation
p
- double[]
public double[] inverse(double[] p) throws java.lang.UnsupportedOperationException
Transformation
inverse
in interface Transformation
p
- double[] the coordinates to be transformed
(the array's contents will be changed accordingly)
java.lang.UnsupportedOperationException
- If the transformation is
not invertiblepublic static XML.ObjectLoader getLoader()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |