|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.matrix.VectorObject
maspack.matrix.Quaternion
Implements a quaternion as a fixed-size 4 element vector. Element 0 is the scalar element, while elements 1-3 are the vector components.
Field Summary | |
double |
s
Scalar element |
Vector3d |
u
Vector element |
Constructor Summary | |
Quaternion()
Creates a Quaternion and initializes its elements to 0. |
|
Quaternion(double s,
double ux,
double uy,
double uz)
Creates a Quaternion with the supplied element values. |
|
Quaternion(Quaternion q)
Creates a Quaternion by copying an existing one. |
Method Summary | |
void |
add(Quaternion q1)
Adds this quaternion to q1 and places the result in this quaternion. |
void |
add(Quaternion q1,
Quaternion q2)
Adds q1 quaternion to q2 and places the result in this quaternion. |
void |
combine(double r1,
Quaternion q1,
double r2,
Quaternion q2)
Computes r1 q1 + r2 q2 and places
the result in this quaternion. |
void |
conjugate()
Conjugates this quaternion in place. |
void |
conjugate(Quaternion q1)
Sets this quaternion to the conjugate of q1. |
double |
distance(Quaternion q)
Returns the Euclidean distance between this quaternion and quaternion q. |
double |
distanceSquared(Quaternion q)
Returns the squared of the Euclidean distance between this quaternion and quaternion q. |
double |
dot(Quaternion q1)
Returns the dot product of this quaternion and q1. |
boolean |
epsilonEquals(Quaternion q1,
double eps)
Returns true if the elements of this quaternion equal those of quaternion q1 within a
prescribed tolerance epsilon . |
boolean |
equals(Quaternion q1)
Returns true if the elements of this quaternion exactly equal those of quaternion q1 . |
void |
get(double[] values)
Copies the elements of this quaternion into an array of doubles. |
double |
get(int i)
Gets a single element of this quaternion. |
double |
infinityNorm()
Returns the infinity norm of this quaternion. |
void |
interpolate(double r,
Quaternion q1)
Computes the interpolation (1-r) this + r q1 and places
the result in this quaternion. |
void |
interpolate(Quaternion q1,
double r,
Quaternion q2)
Computes the interpolation (1-r) q1 + r q2 and places
the result in this quaternion. |
void |
invert()
Inverts this quaternion in place. |
void |
invert(Quaternion q1)
Sets this quaternion to the inverse of q1. |
double |
length()
Returns the 2 norm of this quaternion. |
double |
lengthSquared()
Returns the square of the 2 norm of this quaternion. |
void |
mul(Quaternion q1)
Multiplies this quaternion by quaternion q1 and places the result in this quaternion. |
void |
mul(Quaternion q1,
Quaternion q2)
Multiplies quaternion q1 by quaternion q2 and places the result in this quaternion. |
void |
mulInverse(Quaternion q1)
Post-multiplies this quaternion by the inverse of quaternion q1 and places the result in this quaternion. |
void |
mulInverseBoth(Quaternion q1,
Quaternion q2)
Multiplies the inverse of quaternion q1 by the inverse of quaternion q2 and places the result in this quaternion. |
void |
mulInverseLeft(Quaternion q1,
Quaternion q2)
Multiplies the inverse of quaternion q1 by quaternion q2 and places the result in this quaternion. |
void |
mulInverseRight(Quaternion q1,
Quaternion q2)
Multiplies quaternion q1 by the inverse of quaternion q2 and places the result in this quaternion. |
void |
negate()
Negates this quaternion in place. |
void |
negate(Quaternion q1)
Sets this quaternion to the negative of q1. |
void |
normalize()
Normalizes this quaternion in place. |
void |
normalize(Quaternion q1)
Computes a unit quaternion in the direction of q1 and places the result in this quaternion. |
void |
normalizedInterpolate(double r,
Quaternion q1)
Computes a normalized rotational interpolation between this quaternion and q1 and places the result in this quaternion. |
void |
normalizedInterpolate(Quaternion q1,
double r,
Quaternion q2)
Computes a normalized rotational interpolation between quaternions q1 and q2 and places the result in this quaternion. |
double |
oneNorm()
Returns the 1 norm of this quaternion. |
double |
rotationAngle(Quaternion q1)
Returns the angular distance between the rotations represented by this quaternion and q1. |
void |
scale(double r)
Scales the elements of this quaternion by r . |
void |
scale(double r,
Quaternion q1)
Scales the elements of quaternion q1 by r and places
the results in this quaternion. |
void |
scaleAdd(double r,
Quaternion q1)
Computes r this + q1 and places
the result in this quaternion. |
void |
scaleAdd(double r,
Quaternion q1,
Quaternion q2)
Computes r q1 + q2 and places
the result in this quaternion. |
void |
set(AxisAngle axisAng)
Sets this quaternion to a unit quaternion corresponding to a specified rotation. |
void |
set(double[] values)
Sets the elements of this quaternion from an array of doubles. |
void |
set(double s,
double ux,
double uy,
double uz)
Sets the elements of this quaternion to the prescribed values. |
void |
set(int i,
double value)
Sets a single element of this quaternion. |
void |
set(Quaternion q1)
Sets the values of this quaternion to those of q1. |
void |
set(RotationMatrix3d R)
Sets this quaternion to a unit quaternion corresponding to a specified rotation. |
void |
setRandom()
Sets the elements of this quaternion to uniformly distributed random values in the range -0.5 (inclusive) to 0.5 (exclusive). |
void |
setRandom(double lower,
double upper)
Sets the elements of this quaternion to uniformly distributed random values in a specified range. |
void |
setRandom(double lower,
double upper,
java.util.Random generator)
Sets the elements of this quaternion to uniformly distributed random values in a specified range, using a supplied random number generator. |
void |
setRandomUnit()
Sets this quaternion to a random unit value. |
void |
setRandomUnit(java.util.Random generator)
Sets this quaternion to a random unit value, using a supplied random number generator. |
void |
setZero()
Sets the elements of this quaternion to zero. |
int |
size()
Returns the size of this quaternion (which is always 4) |
void |
sphericalInterpolate(double r,
Quaternion q1)
Computes a spherical (great circle) interpolation between this quaternion and q1 and places the result in this quaternion. |
void |
sphericalInterpolate(Quaternion q1,
double r,
Quaternion q2)
Computes a spherical (great circle) interpolation between quaternions q1 and q2 and places the result in this quaternion. |
void |
sub(Quaternion q1)
Subtracts q1 from this quaternion and places the result in this quaternion. |
void |
sub(Quaternion q1,
Quaternion q2)
Subtracts quaternion q1 from q2 and places the result in this quaternion. |
Methods inherited from class maspack.matrix.VectorObject |
dot, epsilonEquals, equals, equals, get, isFixedSize, maxElement, minElement, norm, normSquared, scan, set, setSize, toString, toString, toString |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public double s
public Vector3d u
Constructor Detail |
public Quaternion()
public Quaternion(Quaternion q)
q
- quaternion to be copiedpublic Quaternion(double s, double ux, double uy, double uz)
s
- scalar elementux
- first vector elementuy
- second vector elementuz
- third vector elementMethod Detail |
public int size()
size
in class VectorObject
public double get(int i)
get
in class VectorObject
i
- element index
public void get(double[] values)
get
in class VectorObject
values
- array into which values are copiedpublic void set(int i, double value)
set
in class VectorObject
i
- element indexvalue
- element value
public void set(double[] values)
set
in class VectorObject
values
- array from which values are copiedpublic void set(Quaternion q1)
q1
- quaternion whose values are copiedpublic void add(Quaternion q1, Quaternion q2)
q1
- left-hand quaternionq2
- right-hand quaternionpublic void add(Quaternion q1)
q1
- right-hand quaternionpublic void sub(Quaternion q1, Quaternion q2)
q1
- left-hand quaternionq2
- right-hand quaternionpublic void sub(Quaternion q1)
q1
- right-hand quaternionpublic void negate(Quaternion q1)
q1
- quaternion to negatepublic void negate()
public void scale(double r)
r
.
r
- scaling factorpublic void scale(double r, Quaternion q1)
r
and places
the results in this quaternion.
r
- scaling factorq1
- quaternion to be scaledpublic void interpolate(Quaternion q1, double r, Quaternion q2)
(1-r) q1 + r q2
and places
the result in this quaternion.
q1
- left-hand quaternionr
- interpolation factorq2
- right-hand quaternionpublic void interpolate(double r, Quaternion q1)
(1-r) this + r q1
and places
the result in this quaternion.
r
- interpolation factorq1
- right-hand quaternionpublic void sphericalInterpolate(Quaternion q1, double r, Quaternion q2)
In the literature, this operation is sometimes known as "Slerp", a name that was coined by Ken Showmake when he described the process in SIGGRAPH 1985.
q1
- left-hand quaternionr
- interpolation factorq2
- right-hand quaternionpublic void normalizedInterpolate(Quaternion q1, double r, Quaternion q2)
This operation is sometimes known as "Nlerp", and is faster than spherical interpolation. Essentially, it involves doing a linear interpolation between q1 qnd q2 and then normalizing the result. q1 and q2 are assumed to be unit quaternions. If they are not, unit versions of them are created internally although this will slow the routine down. Also, if -q1 is closer to q2 than q1, then the interpolation is done between -q1 and q2; this ensures that the shortest rotationa; path is used.
q1
- left-hand quaternionr
- interpolation factorq2
- right-hand quaternionpublic void sphericalInterpolate(double r, Quaternion q1)
r
- interpolation factorq1
- right-hand quaternionpublic void normalizedInterpolate(double r, Quaternion q1)
r
- interpolation factorq1
- right-hand quaternionnormalizedInterpolate(Quaternion,double,Quaternion)
public void scaleAdd(double r, Quaternion q1)
r this + q1
and places
the result in this quaternion.
r
- scaling factorq1
- quaternion to be addedpublic void scaleAdd(double r, Quaternion q1, Quaternion q2)
r q1 + q2
and places
the result in this quaternion.
r
- scaling factorq1
- quaternion to be scaledq2
- quaternion to be addedpublic void combine(double r1, Quaternion q1, double r2, Quaternion q2)
r1 q1 + r2 q2
and places
the result in this quaternion.
r1
- left-hand scaling factorq1
- left-hand quaternionr2
- right-hand scaling factorq2
- right-hand quaternionpublic double length()
public double lengthSquared()
public void conjugate(Quaternion q1)
q1
- quaternion to conjugatepublic void conjugate()
public void invert(Quaternion q1)
q1
- quaternion to invertpublic void invert()
public void mul(Quaternion q1)
q1
- right-hand quaternionpublic void mul(Quaternion q1, Quaternion q2)
q1
- left-hand quaternionq2
- right-hand quaternionpublic void mulInverse(Quaternion q1)
q1
- right-hand quaternionpublic void mulInverseRight(Quaternion q1, Quaternion q2)
q1
- left-hand quaternionq2
- right-hand quaternionpublic void mulInverseLeft(Quaternion q1, Quaternion q2)
q1
- left-hand quaternionq2
- right-hand quaternionpublic void mulInverseBoth(Quaternion q1, Quaternion q2)
q1
- left-hand quaternionq2
- right-hand quaternionpublic double distance(Quaternion q)
public double distanceSquared(Quaternion q)
public double infinityNorm()
infinityNorm
in class VectorObject
public double oneNorm()
oneNorm
in class VectorObject
public double dot(Quaternion q1)
q1
- right-hand quaternion
public double rotationAngle(Quaternion q1)
q1
- right-hand quaternion
public void normalize()
public void normalize(Quaternion q1)
q1
- quaternion to normalizepublic boolean epsilonEquals(Quaternion q1, double eps)
q1
within a
prescribed tolerance epsilon
.
q1
- quaternion to compare witheps
- comparison tolerance
public boolean equals(Quaternion q1)
q1
.
q1
- quaternion to compare with
public void set(AxisAngle axisAng)
axisAng
- gives the rotation axis and corresponding anglepublic void set(RotationMatrix3d R)
R
- rotation specified as a matrixpublic void setZero()
public void set(double s, double ux, double uy, double uz)
s
- scalar valueux
- first vector valueuy
- second vector valueuz
- thirs vector valuepublic void setRandomUnit()
public void setRandomUnit(java.util.Random generator)
generator
- random number generatorpublic void setRandom()
public void setRandom(double lower, double upper)
lower
- lower random value (inclusive)upper
- upper random value (exclusive)public void setRandom(double lower, double upper, java.util.Random generator)
lower
- lower random value (inclusive)upper
- upper random value (exclusive)generator
- random number generator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |