|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.math.Quaternion4f
public class Quaternion4f
A 4-element quaternion that represents the orientation of an object in space.
Quaternions are typically used as a replacement for euler angles and rotation matrices as a way to achieve smooth interpolation and avoid gimbal lock.
Note that this quaternion class does not automatically keep the quaternion
normalized. Therefore, care must be taken to normalize the quaternion when
neccessary, by calling the normalize
method.
Field Summary | ||
---|---|---|
float |
w
The scalar component of the quaternion. |
|
float |
x
The x-value of the quaternion's vector component. |
|
float |
y
The y-value of the quaternion's vector component. |
|
float |
z
The z-value of the quaternion's vector component. |
Constructor Summary | ||
---|---|---|
Quaternion4f()
Constructs a quaternion initialized to (0, 0, 0, 1). |
||
Quaternion4f(float x,
float y,
float z,
float w)
Constructs a new quaternion. |
||
Quaternion4f(Quaternion4f q)
Constructs a new quaternion that is a copy of the specified one. |
Method Summary | ||
---|---|---|
void |
conjugate()
Sets this quaternion to the conjugate of itself. |
|
void |
conjugate(Quaternion4f dst)
Stores the conjugate of this quaternion in dst . |
|
boolean |
equals(Object obj)
Determines if the specified object is equal to this quaternion. |
|
boolean |
equals(Quaternion4f q)
Determines if the specified quaternion is equal to this one. |
|
int |
hashCode()
Returns the hash code of the quaternion, based on the values stored in it. |
|
boolean |
inverse()
Sets this quaternion to the inverse of itself. |
|
boolean |
inverse(Quaternion4f dst)
Stores the inverse of this quaternion in dst . |
|
boolean |
isIdentity()
Determines if this quaterion is equal to the identity quaternion. |
|
void |
multiply(Quaternion4f q)
Multiplies this quaternion by the specified one and stores the result in this quaternion. |
|
static void |
multiply(Quaternion4f q1,
Quaternion4f q2,
Quaternion4f dst)
Multiplies the specified quaternions and stores the result in dst . |
|
void |
normalize()
Normalizes this quaternion to have unit length. |
|
void |
normalize(Quaternion4f dst)
Normalizes this quaternion and stores the result in dst . |
|
void |
set(float x,
float y,
float z,
float w)
Sets the elements of the quaternion to the specified values. |
|
void |
set(float[] array,
int offset)
Sets the elements of the quaternion from the values in the specified array. |
|
void |
set(Matrix4f m)
Sets this quaternion equal to the rotational part of the specified matrix. |
|
void |
set(Quaternion4f q)
Sets the elements of this quaternion to a copy of the specified quaternion. |
|
void |
set(Vector3f axis,
float angle)
Sets this quaternion equal to the rotation from the specified axis and angle. |
|
void |
setIdentity()
Sets this quaternion to be equal to the identity quaternion. |
|
static void |
slerp(Quaternion4f q1,
Quaternion4f q2,
float t,
Quaternion4f dst)
Interpolates between two quaternions using spherical linear interpolation. |
|
String |
toString()
Returns a String representation of the elements of this quaternion. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public float x
public float y
public float z
public float w
Constructor Detail |
---|
public Quaternion4f()
public Quaternion4f(float x, float y, float z, float w)
x
- the x-valuey
- the y-valuez
- the z-valuew
- the w-valuepublic Quaternion4f(Quaternion4f q)
q
- the quaternion to copyMethod Detail |
---|
public final void conjugate()
public final void conjugate(Quaternion4f dst)
dst
.
dst
- a quaternion to store the conjugate inpublic boolean equals(Object obj)
equals
in class Object
obj
- the object to compare
obj
is an instance of Quaternion4f and if
all its components equal this oneBoolean.hashCode()
,
Hashtable
public boolean equals(Quaternion4f q)
q
- the quaternion to compare
public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
Hashtable
public final boolean inverse()
Note that the inverse of a quaternion is equal to its conjugate
when the quaternion is unit-length. For this reason, it is more
efficient to use the conjugate
method directly
when you know your quaternion is already unit-length.
public final boolean inverse(Quaternion4f dst)
dst
.
Note that the inverse of a quaternion is equal to its conjugate
when the quaternion is unit-length. For this reason, it is more
efficient to use the conjugate
method directly
when you know your quaternion is already unit-length.
dst
- a quaternion to store the inverse in
public final boolean isIdentity()
public final void multiply(Quaternion4f q)
q
- the quaternion to multiplypublic static void multiply(Quaternion4f q1, Quaternion4f q2, Quaternion4f dst)
dst
.
q1
- the first quaternionq2
- the second quaterniondst
- a quaternion to store the result inpublic final void normalize()
If the quaternion already has unit length or if the length of the quaternion is zero, this method does nothing.
public final void normalize(Quaternion4f dst)
dst
.
If the quaternion already has unit length or if the length of the
quaternion is zero, this method simply copies this vector into dst
.
dst
- a quaternion to store the result inpublic final void set(float x, float y, float z, float w)
x
- the new x-valuey
- the new y-valuez
- the new z-valuew
- the new w-valuepublic final void set(float[] array, int offset)
array
- an array containing the elements of the quaternion in the order x, y, z, w.offset
- the offset into the array of the x
elementpublic final void set(Matrix4f m)
m
- the matrixpublic final void set(Quaternion4f q)
q
- the quaternion to copypublic final void set(Vector3f axis, float angle)
axis
- a vector describing the axis of rotationangle
- the angle of rotation, in radianspublic final void setIdentity()
public static void slerp(Quaternion4f q1, Quaternion4f q2, float t, Quaternion4f dst)
Spherical linear interpolation provides smooth transitions between different orientations and is often useful for animating models or cameras in 3D.
Note: For accurate interpolation, the input quaternions must be at (or close to)
unit length. This method does not automatically normalize the input quaternions, so it
is up to the caller to ensure they call normalize
beforehand, if necessary.
q1
- the first quaternionq2
- the second quaterniont
- the interpolation coefficientdst
- a quaternion to store the result inpublic String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.