public class Quaternion extends Object
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static Quaternion |
IDENTITY |
Indicates a quaternion whose components are all
1. |
static Quaternion |
ZERO |
Indicates a quaternion whose components are all
0. |
| 构造器 | 说明 |
|---|---|
Quaternion(float[] data,
int offset) |
Creates a quaternion from a one-dimensional float array.
|
Quaternion(float quatX,
float quatY,
float quatZ,
float quatW) |
Creates a quaternion.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static Quaternion |
add(Quaternion lhs,
float rhs) |
Adds a float value to each component of a quaternion.
|
static Quaternion |
add(Quaternion lhs,
Quaternion rhs) |
Adds two quaternions.
|
static Quaternion |
angleAxis(float angleRadians,
Vector3 axis) |
Creates a quaternion by specifying the rotation angle and axis.
|
static Quaternion |
conjugate(float quatX,
float quatY,
float quatZ,
float quatW) |
Conjugates a quaternion based on its components.
|
static float |
dot(Quaternion lhs,
Quaternion rhs) |
Calculates the dot product of two quaternions.
|
boolean |
equals(Object other) |
Indicates whether some other object is "equal to" this one.
|
Quaternion |
getConjugate() |
Obtains a conjugated quaternion.
|
float |
getLength() |
Obtains the length of a quaternion.
|
float |
getLengthSquared() |
Obtains the squared length of a quaternion.
|
Quaternion |
getNormalized() |
Obtains a normalized quaternion.
|
float |
getW() |
Obtains component W of a quaternion.
|
float |
getX() |
Obtains component X of a quaternion.
|
float |
getY() |
Obtains component Y of a quaternion.
|
float |
getZ() |
Obtains component Z of a quaternion.
|
int |
hashCode() |
Returns a hash code value for the object.
|
static float |
length(float quatX,
float quatY,
float quatZ,
float quatW) |
Calculates the length of a quaternion based on its components.
|
static float |
lengthSquared(float quatX,
float quatY,
float quatZ,
float quatW) |
Calculates the squared length of a quaternion based on its components.
|
static Quaternion |
multiply(Quaternion lhs,
float rhs) |
Multiplies each component of a quaternion by a float value.
|
static Quaternion |
multiply(Quaternion lhs,
Quaternion rhs) |
Multiplies two quaternions.
|
static Quaternion |
normalize(float quatX,
float quatY,
float quatZ,
float quatW) |
Normalizes a quaternion based on its components.
|
Vector3 |
rotatePoint(Vector3 vector) |
Rotates a given vector to obtain a new vector.
|
static Quaternion |
slerp(Quaternion lhs,
Quaternion rhs,
float value) |
Performs spherical linear interpolation between two quaternions.
|
static Quaternion |
subtract(Quaternion lhs,
float rhs) |
Subtracts a float value from each component of a quaternion.
|
static Quaternion |
subtract(Quaternion lhs,
Quaternion rhs) |
Subtracts each component of a quaternion from that of another quaternion.
|
String |
toString() |
Returns a string representation of the object.
|
public static final Quaternion IDENTITY
1.public static final Quaternion ZERO
0.public Quaternion(float[] data,
int offset)
data - Indicates the float array.offset - Indicates the array offset, from which data copying starts.public Quaternion(float quatX,
float quatY,
float quatZ,
float quatW)
quatX - Indicates component X.quatY - Indicates component Y.quatZ - Indicates component Z.quatW - Indicates component W.public static Quaternion add(Quaternion lhs, Quaternion rhs)
This method adds each component of a quaternion to that of another quaternion.
lhs - Indicates the left-hand-side operand.rhs - Indicates the right-hand-side operand.public static Quaternion add(Quaternion lhs, float rhs)
lhs - Indicates the left-hand-side operand.rhs - Indicates the right-hand-side operand.public static Quaternion subtract(Quaternion lhs, Quaternion rhs)
lhs - Indicates the left-hand-side quaternion.rhs - Indicates the right-hand-side quaternion.public static Quaternion subtract(Quaternion lhs, float rhs)
lhs - Indicates the left-hand-side operand.rhs - Indicates the right-hand-side operand.public static Quaternion multiply(Quaternion lhs, Quaternion rhs)
lhs - Indicates the left-hand-side operand.rhs - Indicates the right-hand-side operand.public static Quaternion multiply(Quaternion lhs, float rhs)
lhs - Indicates the left-hand-side operand.rhs - Indicates the right-hand-side operand.public static float dot(Quaternion lhs, Quaternion rhs)
lhs - Indicates the left-hand-side operand.rhs - Indicates the right-hand-side operand.public static Quaternion angleAxis(float angleRadians, Vector3 axis)
angleRadians - Indicates the angle to rotate the quaternion.axis - Indicates the axis based on which to rotate the quaternion.public static float length(float quatX,
float quatY,
float quatZ,
float quatW)
quatX - Indicates component X.quatY - Indicates component Y.quatZ - Indicates component Z.quatW - Indicates component W.public static float lengthSquared(float quatX,
float quatY,
float quatZ,
float quatW)
quatX - Indicates component X.quatY - Indicates component Y.quatZ - Indicates component Z.quatW - Indicates component W.public static Quaternion normalize(float quatX, float quatY, float quatZ, float quatW)
quatX - Indicates component X.quatY - Indicates component Y.quatZ - Indicates component Z.quatW - Indicates component W.IDENTITY otherwise.public static Quaternion conjugate(float quatX, float quatY, float quatZ, float quatW)
quatX - Indicates component X.quatY - Indicates component Y.quatZ - Indicates component Z.quatW - Indicates component W.public static Quaternion slerp(Quaternion lhs, Quaternion rhs, float value)
lhs - Indicates the left-hand-side operand.rhs - Indicates the right-hand-side operand.value - Indicates the interpolation proportion, which ranges from 0.0 to 1.0.public float getX()
public float getY()
public float getZ()
public float getW()
public float getLength()
For details about how to calculate the length of a quaternion, see length(float, float, float, float).
public float getLengthSquared()
For details about how to calculate the squared length of a quaternion, see lengthSquared(float, float, float, float).
public Quaternion getNormalized()
For details about how to normalize a quaternion, see normalize(float, float, float, float).
public Quaternion getConjugate()
For details about how to conjugate a quaternion, see conjugate(float, float, float, float).
public Vector3 rotatePoint(Vector3 vector)
vector - Indicates the given vector.public boolean equals(Object other)
Object
The equals method implements an equivalence relation
on non-null object references:
x, x.equals(x) should return
true.
x and y, x.equals(y)
should return true if and only if
y.equals(x) returns true.
x, y, and z, if
x.equals(y) returns true and
y.equals(z) returns true, then
x.equals(z) should return true.
x and y, multiple invocations of
x.equals(y) consistently return true
or consistently return false, provided no
information used in equals comparisons on the
objects is modified.
x,
x.equals(null) should return false.
The equals method for class Object implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x and
y, this method returns true if and only
if x and y refer to the same object
(x == y has the value true).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode method, which states
that equal objects must have equal hash codes.
equals 在类中 Objectother - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.Object.hashCode(),
HashMappublic int hashCode()
ObjectHashMap.
The general contract of hashCode is:
hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
hashCode 在类中 ObjectObject.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)public String toString()
ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())