com.jme3.math
クラス Quaternion

java.lang.Object
  上位を拡張 com.jme3.math.Quaternion
すべての実装されたインタフェース:
Savable, java.io.Serializable, java.lang.Cloneable

public final class Quaternion
extends java.lang.Object
implements Savable, java.lang.Cloneable, java.io.Serializable

Quaternion defines a single example of a more general class of hypercomplex numbers. Quaternions extends a rotation in three dimensions to a rotation in four dimensions. This avoids "gimbal lock" and allows for smooth continuous rotation. Quaternion is defined by four floating point numbers: {x y z w}.

関連項目:
直列化された形式

フィールドの概要
static Quaternion DIRECTION_Z
           
static Quaternion IDENTITY
          Represents the identity quaternion rotation (0, 0, 0, 1).
static Quaternion ZERO
           
 
コンストラクタの概要
Quaternion()
          Constructor instantiates a new Quaternion object initializing all values to zero, except w which is initialized to 1.
Quaternion(float[] angles)
          Constructor instantiates a new Quaternion object from a collection of rotation angles.
Quaternion(float x, float y, float z, float w)
          Constructor instantiates a new Quaternion object from the given list of parameters.
Quaternion(Quaternion q)
          Constructor instantiates a new Quaternion object from an existing quaternion, creating a copy.
Quaternion(Quaternion q1, Quaternion q2, float interp)
          Constructor instantiates a new Quaternion object from an interpolation between two other quaternions.
 
メソッドの概要
 Quaternion add(Quaternion q)
          add adds the values of this quaternion to those of the parameter quaternion.
 Quaternion addLocal(Quaternion q)
          add adds the values of this quaternion to those of the parameter quaternion.
 void apply(Matrix3f matrix)
          apply multiplies this quaternion by a parameter matrix internally.
 Quaternion clone()
           
 float dot(Quaternion q)
          dot calculates and returns the dot product of this quaternion with that of the parameter quaternion.
 boolean equals(java.lang.Object o)
          equals determines if two quaternions are logically equal, that is, if the values of (x, y, z, w) are the same for both quaternions.
 Quaternion fromAngleAxis(float angle, Vector3f axis)
          fromAngleAxis sets this quaternion to the values specified by an angle and an axis of rotation.
 Quaternion fromAngleNormalAxis(float angle, Vector3f axis)
          fromAngleNormalAxis sets this quaternion to the values specified by an angle and a normalized axis of rotation.
 Quaternion fromAngles(float[] angles)
          fromAngles builds a quaternion from the Euler rotation angles (y,r,p).
 Quaternion fromAngles(float yaw, float roll, float pitch)
          fromAngles builds a Quaternion from the Euler rotation angles (y,r,p).
 Quaternion fromAxes(Vector3f[] axis)
          fromAxes creates a Quaternion that represents the coordinate system defined by three axes.
 Quaternion fromAxes(Vector3f xAxis, Vector3f yAxis, Vector3f zAxis)
          fromAxes creates a Quaternion that represents the coordinate system defined by three axes.
 Quaternion fromRotationMatrix(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
           
 Quaternion fromRotationMatrix(Matrix3f matrix)
          fromRotationMatrix generates a quaternion from a supplied matrix.
 Vector3f getRotationColumn(int i)
          getRotationColumn returns one of three columns specified by the parameter.
 Vector3f getRotationColumn(int i, Vector3f store)
          getRotationColumn returns one of three columns specified by the parameter.
 float getW()
           
 float getX()
           
 float getY()
           
 float getZ()
           
 int hashCode()
          hashCode returns the hash code value as an integer and is supported for the benefit of hashing based collection classes such as Hashtable, HashMap, HashSet etc.
 Quaternion inverse()
          inverse returns the inverse of this quaternion as a new quaternion.
 Quaternion inverseLocal()
          inverse calculates the inverse of this quaternion and returns this quaternion after it is calculated.
 boolean isIdentity()
           
 void loadIdentity()
          Sets this Quaternion to {0, 0, 0, 1}.
 void lookAt(Vector3f direction, Vector3f up)
          lookAt is a convienence method for auto-setting the quaternion based on a direction and an up vector.
 Quaternion mult(float scalar)
          mult multiplies this quaternion by a parameter scalar.
 Quaternion mult(Quaternion q)
          mult multiplies this quaternion by a parameter quaternion.
 Quaternion mult(Quaternion q, Quaternion res)
          mult multiplies this quaternion by a parameter quaternion.
 Vector3f mult(Vector3f v)
          mult multiplies this quaternion by a parameter vector.
 Vector3f mult(Vector3f v, Vector3f store)
          mult multiplies this quaternion by a parameter vector.
 Quaternion multLocal(float scalar)
          mult multiplies this quaternion by a parameter scalar.
 Quaternion multLocal(float qx, float qy, float qz, float qw)
          Multiplies this Quaternion by the supplied quaternion.
 Quaternion multLocal(Quaternion q)
          Multiplies this Quaternion by the supplied quaternion.
 Vector3f multLocal(Vector3f v)
          mult multiplies this quaternion by a parameter vector.
 void negate()
          negate inverts the values of the quaternion.
 void nlerp(Quaternion q2, float blend)
          Sets the values of this quaternion to the nlerp from itself to q2 by blend.
 float norm()
          norm returns the norm of this quaternion.
 void normalize()
          推奨されていません。 The naming of this method doesn't follow convention. Please use normalizeLocal() instead.
 void normalizeLocal()
          normalize normalizes the current Quaternion
 Quaternion opposite()
           
 Quaternion opposite(Quaternion store)
          FIXME: This seems to have singularity type issues with angle == 0, possibly others such as PI.
 Quaternion oppositeLocal()
           
 void read(JmeImporter e)
           
 void readExternal(java.io.ObjectInput in)
          readExternal builds a quaternion from an ObjectInput object.
 Quaternion set(float x, float y, float z, float w)
          sets the data in a Quaternion object from the given list of parameters.
 Quaternion set(Quaternion q)
          Sets the data in this Quaternion object to be equal to the passed Quaternion object.
 void slerp(Quaternion q2, float changeAmnt)
          Sets the values of this quaternion to the slerp from itself to q2 by changeAmnt
 Quaternion slerp(Quaternion q1, Quaternion q2, float t)
          slerp sets this quaternion's value as an interpolation between two other quaternions.
 Quaternion subtract(Quaternion q)
          subtract subtracts the values of the parameter quaternion from those of this quaternion.
 Quaternion subtractLocal(Quaternion q)
          subtract subtracts the values of the parameter quaternion from those of this quaternion.
 float toAngleAxis(Vector3f axisStore)
          toAngleAxis sets a given angle and axis to that represented by the current quaternion.
 float[] toAngles(float[] angles)
          toAngles returns this quaternion converted to Euler rotation angles (yaw,roll,pitch).
 void toAxes(Vector3f[] axis)
          toAxes takes in an array of three vectors.
 Matrix3f toRotationMatrix()
          toRotationMatrix converts this quaternion to a rotational matrix.
 Matrix3f toRotationMatrix(Matrix3f result)
          toRotationMatrix converts this quaternion to a rotational matrix.
 Matrix4f toRotationMatrix(Matrix4f result)
          toRotationMatrix converts this quaternion to a rotational matrix.
 java.lang.String toString()
          toString creates the string representation of this Quaternion.
 void write(JmeExporter e)
           
 void writeExternal(java.io.ObjectOutput out)
          writeExternal writes this quaternion out to a ObjectOutput object.
 
クラス java.lang.Object から継承されたメソッド
getClass, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

IDENTITY

public static final Quaternion IDENTITY
Represents the identity quaternion rotation (0, 0, 0, 1).


DIRECTION_Z

public static final Quaternion DIRECTION_Z

ZERO

public static final Quaternion ZERO
コンストラクタの詳細

Quaternion

public Quaternion()
Constructor instantiates a new Quaternion object initializing all values to zero, except w which is initialized to 1.


Quaternion

public Quaternion(float x,
                  float y,
                  float z,
                  float w)
Constructor instantiates a new Quaternion object from the given list of parameters.

パラメータ:
x - the x value of the quaternion.
y - the y value of the quaternion.
z - the z value of the quaternion.
w - the w value of the quaternion.

Quaternion

public Quaternion(float[] angles)
Constructor instantiates a new Quaternion object from a collection of rotation angles.

パラメータ:
angles - the angles of rotation (x, y, z) that will define the Quaternion.

Quaternion

public Quaternion(Quaternion q1,
                  Quaternion q2,
                  float interp)
Constructor instantiates a new Quaternion object from an interpolation between two other quaternions.

パラメータ:
q1 - the first quaternion.
q2 - the second quaternion.
interp - the amount to interpolate between the two quaternions.

Quaternion

public Quaternion(Quaternion q)
Constructor instantiates a new Quaternion object from an existing quaternion, creating a copy.

パラメータ:
q - the quaternion to copy.
メソッドの詳細

getX

public float getX()

getY

public float getY()

getZ

public float getZ()

getW

public float getW()

set

public Quaternion set(float x,
                      float y,
                      float z,
                      float w)
sets the data in a Quaternion object from the given list of parameters.

パラメータ:
x - the x value of the quaternion.
y - the y value of the quaternion.
z - the z value of the quaternion.
w - the w value of the quaternion.
戻り値:
this

set

public Quaternion set(Quaternion q)
Sets the data in this Quaternion object to be equal to the passed Quaternion object. The values are copied producing a new object.

パラメータ:
q - The Quaternion to copy values from.
戻り値:
this

loadIdentity

public void loadIdentity()
Sets this Quaternion to {0, 0, 0, 1}. Same as calling set(0,0,0,1).


isIdentity

public boolean isIdentity()
戻り値:
true if this Quaternion is {0,0,0,1}

fromAngles

public Quaternion fromAngles(float[] angles)
fromAngles builds a quaternion from the Euler rotation angles (y,r,p).

パラメータ:
angles - the Euler angles of rotation (in radians).

fromAngles

public Quaternion fromAngles(float yaw,
                             float roll,
                             float pitch)
fromAngles builds a Quaternion from the Euler rotation angles (y,r,p). Note that we are applying in order: roll, pitch, yaw but we've ordered them in x, y, and z for convenience. See: http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm

パラメータ:
yaw - the Euler yaw of rotation (in radians). (aka Bank, often rot around x)
roll - the Euler roll of rotation (in radians). (aka Heading, often rot around y)
pitch - the Euler pitch of rotation (in radians). (aka Attitude, often rot around z)

toAngles

public float[] toAngles(float[] angles)
toAngles returns this quaternion converted to Euler rotation angles (yaw,roll,pitch).
See http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm

パラメータ:
angles - the float[] in which the angles should be stored, or null if you want a new float[] to be created
戻り値:
the float[] in which the angles are stored.

fromRotationMatrix

public Quaternion fromRotationMatrix(Matrix3f matrix)
fromRotationMatrix generates a quaternion from a supplied matrix. This matrix is assumed to be a rotational matrix.

パラメータ:
matrix - the matrix that defines the rotation.

fromRotationMatrix

public Quaternion fromRotationMatrix(float m00,
                                     float m01,
                                     float m02,
                                     float m10,
                                     float m11,
                                     float m12,
                                     float m20,
                                     float m21,
                                     float m22)

toRotationMatrix

public Matrix3f toRotationMatrix()
toRotationMatrix converts this quaternion to a rotational matrix. Note: the result is created from a normalized version of this quat.

戻り値:
the rotation matrix representation of this quaternion.

toRotationMatrix

public Matrix3f toRotationMatrix(Matrix3f result)
toRotationMatrix converts this quaternion to a rotational matrix. The result is stored in result.

パラメータ:
result - The Matrix3f to store the result in.
戻り値:
the rotation matrix representation of this quaternion.

toRotationMatrix

public Matrix4f toRotationMatrix(Matrix4f result)
toRotationMatrix converts this quaternion to a rotational matrix. The result is stored in result. 4th row and 4th column values are untouched. Note: the result is created from a normalized version of this quat.

パラメータ:
result - The Matrix4f to store the result in.
戻り値:
the rotation matrix representation of this quaternion.

getRotationColumn

public Vector3f getRotationColumn(int i)
getRotationColumn returns one of three columns specified by the parameter. This column is returned as a Vector3f object.

パラメータ:
i - the column to retrieve. Must be between 0 and 2.
戻り値:
the column specified by the index.

getRotationColumn

public Vector3f getRotationColumn(int i,
                                  Vector3f store)
getRotationColumn returns one of three columns specified by the parameter. This column is returned as a Vector3f object. The value is retrieved as if this quaternion was first normalized.

パラメータ:
i - the column to retrieve. Must be between 0 and 2.
store - the vector object to store the result in. if null, a new one is created.
戻り値:
the column specified by the index.

fromAngleAxis

public Quaternion fromAngleAxis(float angle,
                                Vector3f axis)
fromAngleAxis sets this quaternion to the values specified by an angle and an axis of rotation. This method creates an object, so use fromAngleNormalAxis if your axis is already normalized.

パラメータ:
angle - the angle to rotate (in radians).
axis - the axis of rotation.
戻り値:
this quaternion

fromAngleNormalAxis

public Quaternion fromAngleNormalAxis(float angle,
                                      Vector3f axis)
fromAngleNormalAxis sets this quaternion to the values specified by an angle and a normalized axis of rotation.

パラメータ:
angle - the angle to rotate (in radians).
axis - the axis of rotation (already normalized).

toAngleAxis

public float toAngleAxis(Vector3f axisStore)
toAngleAxis sets a given angle and axis to that represented by the current quaternion. The values are stored as following: The axis is provided as a parameter and built by the method, the angle is returned as a float.

パラメータ:
axisStore - the object we'll store the computed axis in.
戻り値:
the angle of rotation in radians.

slerp

public Quaternion slerp(Quaternion q1,
                        Quaternion q2,
                        float t)
slerp sets this quaternion's value as an interpolation between two other quaternions.

パラメータ:
q1 - the first quaternion.
q2 - the second quaternion.
t - the amount to interpolate between the two quaternions.

slerp

public void slerp(Quaternion q2,
                  float changeAmnt)
Sets the values of this quaternion to the slerp from itself to q2 by changeAmnt

パラメータ:
q2 - Final interpolation value
changeAmnt - The amount diffrence

nlerp

public void nlerp(Quaternion q2,
                  float blend)
Sets the values of this quaternion to the nlerp from itself to q2 by blend.

パラメータ:
q2 -
blend -

add

public Quaternion add(Quaternion q)
add adds the values of this quaternion to those of the parameter quaternion. The result is returned as a new quaternion.

パラメータ:
q - the quaternion to add to this.
戻り値:
the new quaternion.

addLocal

public Quaternion addLocal(Quaternion q)
add adds the values of this quaternion to those of the parameter quaternion. The result is stored in this Quaternion.

パラメータ:
q - the quaternion to add to this.
戻り値:
This Quaternion after addition.

subtract

public Quaternion subtract(Quaternion q)
subtract subtracts the values of the parameter quaternion from those of this quaternion. The result is returned as a new quaternion.

パラメータ:
q - the quaternion to subtract from this.
戻り値:
the new quaternion.

subtractLocal

public Quaternion subtractLocal(Quaternion q)
subtract subtracts the values of the parameter quaternion from those of this quaternion. The result is stored in this Quaternion.

パラメータ:
q - the quaternion to subtract from this.
戻り値:
This Quaternion after subtraction.

mult

public Quaternion mult(Quaternion q)
mult multiplies this quaternion by a parameter quaternion. The result is returned as a new quaternion. It should be noted that quaternion multiplication is not commutative so q * p != p * q.

パラメータ:
q - the quaternion to multiply this quaternion by.
戻り値:
the new quaternion.

mult

public Quaternion mult(Quaternion q,
                       Quaternion res)
mult multiplies this quaternion by a parameter quaternion. The result is returned as a new quaternion. It should be noted that quaternion multiplication is not commutative so q * p != p * q. It IS safe for q and res to be the same object. It IS safe for this and res to be the same object.

パラメータ:
q - the quaternion to multiply this quaternion by.
res - the quaternion to store the result in.
戻り値:
the new quaternion.

apply

public void apply(Matrix3f matrix)
apply multiplies this quaternion by a parameter matrix internally.

パラメータ:
matrix - the matrix to apply to this quaternion.

fromAxes

public Quaternion fromAxes(Vector3f[] axis)
fromAxes creates a Quaternion that represents the coordinate system defined by three axes. These axes are assumed to be orthogonal and no error checking is applied. Thus, the user must insure that the three axes being provided indeed represents a proper right handed coordinate system.

パラメータ:
axis - the array containing the three vectors representing the coordinate system.

fromAxes

public Quaternion fromAxes(Vector3f xAxis,
                           Vector3f yAxis,
                           Vector3f zAxis)
fromAxes creates a Quaternion that represents the coordinate system defined by three axes. These axes are assumed to be orthogonal and no error checking is applied. Thus, the user must insure that the three axes being provided indeed represents a proper right handed coordinate system.

パラメータ:
xAxis - vector representing the x-axis of the coordinate system.
yAxis - vector representing the y-axis of the coordinate system.
zAxis - vector representing the z-axis of the coordinate system.

toAxes

public void toAxes(Vector3f[] axis)
toAxes takes in an array of three vectors. Each vector corresponds to an axis of the coordinate system defined by the quaternion rotation.

パラメータ:
axis - the array of vectors to be filled.

mult

public Vector3f mult(Vector3f v)
mult multiplies this quaternion by a parameter vector. The result is returned as a new vector.

パラメータ:
v - the vector to multiply this quaternion by.
戻り値:
the new vector.

multLocal

public Vector3f multLocal(Vector3f v)
mult multiplies this quaternion by a parameter vector. The result is stored in the supplied vector

パラメータ:
v - the vector to multiply this quaternion by.
戻り値:
v

multLocal

public Quaternion multLocal(Quaternion q)
Multiplies this Quaternion by the supplied quaternion. The result is stored in this Quaternion, which is also returned for chaining. Similar to this *= q.

パラメータ:
q - The Quaternion to multiply this one by.
戻り値:
This Quaternion, after multiplication.

multLocal

public Quaternion multLocal(float qx,
                            float qy,
                            float qz,
                            float qw)
Multiplies this Quaternion by the supplied quaternion. The result is stored in this Quaternion, which is also returned for chaining. Similar to this *= q.

パラメータ:
qx - - quat x value
qy - - quat y value
qz - - quat z value
qw - - quat w value
戻り値:
This Quaternion, after multiplication.

mult

public Vector3f mult(Vector3f v,
                     Vector3f store)
mult multiplies this quaternion by a parameter vector. The result is returned as a new vector.

パラメータ:
v - the vector to multiply this quaternion by.
store - the vector to store the result in. It IS safe for v and store to be the same object.
戻り値:
the result vector.

mult

public Quaternion mult(float scalar)
mult multiplies this quaternion by a parameter scalar. The result is returned as a new quaternion.

パラメータ:
scalar - the quaternion to multiply this quaternion by.
戻り値:
the new quaternion.

multLocal

public Quaternion multLocal(float scalar)
mult multiplies this quaternion by a parameter scalar. The result is stored locally.

パラメータ:
scalar - the quaternion to multiply this quaternion by.
戻り値:
this.

dot

public float dot(Quaternion q)
dot calculates and returns the dot product of this quaternion with that of the parameter quaternion.

パラメータ:
q - the quaternion to calculate the dot product of.
戻り値:
the dot product of this and the parameter quaternion.

norm

public float norm()
norm returns the norm of this quaternion. This is the dot product of this quaternion with itself.

戻り値:
the norm of the quaternion.

normalize

@Deprecated
public void normalize()
推奨されていません。 The naming of this method doesn't follow convention. Please use normalizeLocal() instead.

normalize normalizes the current Quaternion


normalizeLocal

public void normalizeLocal()
normalize normalizes the current Quaternion


inverse

public Quaternion inverse()
inverse returns the inverse of this quaternion as a new quaternion. If this quaternion does not have an inverse (if its normal is 0 or less), then null is returned.

戻り値:
the inverse of this quaternion or null if the inverse does not exist.

inverseLocal

public Quaternion inverseLocal()
inverse calculates the inverse of this quaternion and returns this quaternion after it is calculated. If this quaternion does not have an inverse (if it's norma is 0 or less), nothing happens

戻り値:
the inverse of this quaternion

negate

public void negate()
negate inverts the values of the quaternion.


toString

public java.lang.String toString()
toString creates the string representation of this Quaternion. The values of the quaternion are displace (x, y, z, w), in the following manner:
(x, y, z, w)

オーバーライド:
クラス java.lang.Object 内の toString
戻り値:
the string representation of this object.
関連項目:
Object.toString()

equals

public boolean equals(java.lang.Object o)
equals determines if two quaternions are logically equal, that is, if the values of (x, y, z, w) are the same for both quaternions.

オーバーライド:
クラス java.lang.Object 内の equals
パラメータ:
o - the object to compare for equality
戻り値:
true if they are equal, false otherwise.

hashCode

public int hashCode()
hashCode returns the hash code value as an integer and is supported for the benefit of hashing based collection classes such as Hashtable, HashMap, HashSet etc.

オーバーライド:
クラス java.lang.Object 内の hashCode
戻り値:
the hashcode for this instance of Quaternion.
関連項目:
Object.hashCode()

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException
readExternal builds a quaternion from an ObjectInput object.
NOTE: Used with serialization. Not to be called manually.

パラメータ:
in - the ObjectInput value to read from.
例外:
java.io.IOException - if the ObjectInput value has problems reading a float.
関連項目:
Externalizable

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
writeExternal writes this quaternion out to a ObjectOutput object. NOTE: Used with serialization. Not to be called manually.

パラメータ:
out - the object to write to.
例外:
java.io.IOException - if writing to the ObjectOutput fails.
関連項目:
Externalizable

lookAt

public void lookAt(Vector3f direction,
                   Vector3f up)
lookAt is a convienence method for auto-setting the quaternion based on a direction and an up vector. It computes the rotation to transform the z-axis to point into 'direction' and the y-axis to 'up'.

パラメータ:
direction - where to look at in terms of local coordinates
up - a vector indicating the local up direction. (typically {0, 1, 0} in jME.)

write

public void write(JmeExporter e)
           throws java.io.IOException
定義:
インタフェース Savable 内の write
例外:
java.io.IOException

read

public void read(JmeImporter e)
          throws java.io.IOException
定義:
インタフェース Savable 内の read
例外:
java.io.IOException

opposite

public Quaternion opposite()
戻り値:
A new quaternion that describes a rotation that would point you in the exact opposite direction of this Quaternion.

opposite

public Quaternion opposite(Quaternion store)
FIXME: This seems to have singularity type issues with angle == 0, possibly others such as PI.

パラメータ:
store - A Quaternion to store our result in. If null, a new one is created.
戻り値:
The store quaternion (or a new Quaterion, if store is null) that describes a rotation that would point you in the exact opposite direction of this Quaternion.

oppositeLocal

public Quaternion oppositeLocal()
戻り値:
This Quaternion, altered to describe a rotation that would point you in the exact opposite direction of where it is pointing currently.

clone

public Quaternion clone()
オーバーライド:
クラス java.lang.Object 内の clone