public class Quaternion extends Object implements Serializable
Constructor and Description |
---|
Quaternion() |
Quaternion(float x,
float y,
float z,
float w)
Constructor, sets the four components of the quaternion.
|
Quaternion(Quaternion quaternion)
Constructor, sets the quaternion components from the given quaternion.
|
Quaternion(Vector3 axis,
float angle)
Constructor, sets the quaternion from the given axis vector and the angle around that axis in degrees.
|
Modifier and Type | Method and Description |
---|---|
Quaternion |
add(float qx,
float qy,
float qz,
float qw)
Add the x,y,z,w components of the passed in quaternion to the ones of this quaternion
|
Quaternion |
add(Quaternion quaternion)
Add the x,y,z,w components of the passed in quaternion to the ones of this quaternion
|
Quaternion |
conjugate()
Conjugate the quaternion.
|
Quaternion |
cpy() |
float |
dot(float x,
float y,
float z,
float w)
Get the dot product between this and the other quaternion (commutative).
|
static float |
dot(float x1,
float y1,
float z1,
float w1,
float x2,
float y2,
float z2,
float w2)
Get the dot product between the two quaternions (commutative).
|
float |
dot(Quaternion other)
Get the dot product between this and the other quaternion (commutative).
|
boolean |
equals(Object obj) |
Quaternion |
exp(float alpha)
Calculates (this quaternion)^alpha where alpha is a real number and stores the result in this quaternion.
|
float |
getAngle()
Get the angle in degrees of the rotation this quaternion represents.
|
float |
getAngleAround(float axisX,
float axisY,
float axisZ)
Get the angle in degrees of the rotation around the specified axis.
|
float |
getAngleAround(Vector3 axis)
Get the angle in degrees of the rotation around the specified axis.
|
float |
getAngleAroundRad(float axisX,
float axisY,
float axisZ)
Get the angle in radians of the rotation around the specified axis.
|
float |
getAngleAroundRad(Vector3 axis)
Get the angle in radians of the rotation around the specified axis.
|
float |
getAngleRad()
Get the angle in radians of the rotation this quaternion represents.
|
float |
getAxisAngle(Vector3 axis)
Get the axis angle representation of the rotation in degrees.
|
float |
getAxisAngleRad(Vector3 axis)
Get the axis-angle representation of the rotation in radians.
|
int |
getGimbalPole()
Get the pole of the gimbal lock, if any.
|
float |
getPitch()
Get the pitch euler angle in degrees, which is the rotation around the x axis.
|
float |
getPitchRad()
Get the pitch euler angle in radians, which is the rotation around the x axis.
|
float |
getRoll()
Get the roll euler angle in degrees, which is the rotation around the z axis.
|
float |
getRollRad()
Get the roll euler angle in radians, which is the rotation around the z axis.
|
void |
getSwingTwist(float axisX,
float axisY,
float axisZ,
Quaternion swing,
Quaternion twist)
Get the swing rotation and twist rotation for the specified axis.
|
void |
getSwingTwist(Vector3 axis,
Quaternion swing,
Quaternion twist)
Get the swing rotation and twist rotation for the specified axis.
|
float |
getYaw()
Get the yaw euler angle in degrees, which is the rotation around the y axis.
|
float |
getYawRad()
Get the yaw euler angle in radians, which is the rotation around the y axis.
|
int |
hashCode() |
Quaternion |
idt()
Sets the quaternion to an identity Quaternion
|
boolean |
isIdentity() |
boolean |
isIdentity(float tolerance) |
float |
len() |
static float |
len(float x,
float y,
float z,
float w) |
float |
len2() |
static float |
len2(float x,
float y,
float z,
float w) |
Quaternion |
mul(float scalar)
Multiplies the components of this quaternion with the given scalar.
|
Quaternion |
mul(float x,
float y,
float z,
float w)
Multiplies this quaternion with another one in the form of this = this * other
|
Quaternion |
mul(Quaternion other)
Multiplies this quaternion with another one in the form of this = this * other
|
Quaternion |
mulLeft(float x,
float y,
float z,
float w)
Multiplies this quaternion with another one in the form of this = other * this
|
Quaternion |
mulLeft(Quaternion other)
Multiplies this quaternion with another one in the form of this = other * this
|
Quaternion |
nor()
Normalizes this quaternion to unit length
|
Quaternion |
set(float x,
float y,
float z,
float w)
Sets the components of the quaternion
|
Quaternion |
set(Quaternion quaternion)
Sets the quaternion components from the given quaternion.
|
Quaternion |
set(Vector3 axis,
float angle)
Sets the quaternion components from the given axis and angle around that axis.
|
Quaternion |
setEulerAngles(float yaw,
float pitch,
float roll)
Sets the quaternion to the given euler angles in degrees.
|
Quaternion |
setEulerAnglesRad(float yaw,
float pitch,
float roll)
Sets the quaternion to the given euler angles in radians.
|
Quaternion |
setFromAxes(boolean normalizeAxes,
float xx,
float xy,
float xz,
float yx,
float yy,
float yz,
float zx,
float zy,
float zz)
Sets the Quaternion from the given x-, y- and z-axis.
|
Quaternion |
setFromAxes(float xx,
float xy,
float xz,
float yx,
float yy,
float yz,
float zx,
float zy,
float zz)
Sets the Quaternion from the given x-, y- and z-axis which have to be orthonormal.
|
Quaternion |
setFromAxis(float x,
float y,
float z,
float degrees)
Sets the quaternion components from the given axis and angle around that axis.
|
Quaternion |
setFromAxis(Vector3 axis,
float degrees)
Sets the quaternion components from the given axis and angle around that axis.
|
Quaternion |
setFromAxisRad(float x,
float y,
float z,
float radians)
Sets the quaternion components from the given axis and angle around that axis.
|
Quaternion |
setFromAxisRad(Vector3 axis,
float radians)
Sets the quaternion components from the given axis and angle around that axis.
|
Quaternion |
setFromCross(float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
Set this quaternion to the rotation between two vectors.
|
Quaternion |
setFromCross(Vector3 v1,
Vector3 v2)
Set this quaternion to the rotation between two vectors.
|
Quaternion |
setFromMatrix(boolean normalizeAxes,
Matrix3 matrix)
Sets the Quaternion from the given matrix, optionally removing any scaling.
|
Quaternion |
setFromMatrix(boolean normalizeAxes,
Matrix4 matrix)
Sets the Quaternion from the given matrix, optionally removing any scaling.
|
Quaternion |
setFromMatrix(Matrix3 matrix)
Sets the Quaternion from the given rotation matrix, which must not contain scaling.
|
Quaternion |
setFromMatrix(Matrix4 matrix)
Sets the Quaternion from the given rotation matrix, which must not contain scaling.
|
Quaternion |
slerp(Quaternion[] q)
Spherical linearly interpolates multiple quaternions and stores the result in this Quaternion.
|
Quaternion |
slerp(Quaternion[] q,
float[] w)
Spherical linearly interpolates multiple quaternions by the given weights and stores the result in this Quaternion.
|
Quaternion |
slerp(Quaternion end,
float alpha)
Spherical linear interpolation between this quaternion and the other quaternion, based on the alpha value in the range
[0,1].
|
void |
toMatrix(float[] matrix)
Fills a 4x4 matrix with the rotation matrix represented by this quaternion.
|
String |
toString() |
Vector3 |
transform(Vector3 v)
Transforms the given vector using this quaternion
|
public Quaternion(float x, float y, float z, float w)
x
- The x-componenty
- The y-componentz
- The z-componentw
- The w-componentpublic Quaternion()
public Quaternion(Quaternion quaternion)
quaternion
- The quaternion to copy.public Quaternion(Vector3 axis, float angle)
axis
- The axisangle
- The angle in degrees.public Quaternion set(float x, float y, float z, float w)
x
- The x-componenty
- The y-componentz
- The z-componentw
- The w-componentpublic Quaternion set(Quaternion quaternion)
quaternion
- The quaternion.public Quaternion set(Vector3 axis, float angle)
axis
- The axisangle
- The angle in degreespublic Quaternion cpy()
public static final float len(float x, float y, float z, float w)
public float len()
public Quaternion setEulerAngles(float yaw, float pitch, float roll)
yaw
- the rotation around the y axis in degreespitch
- the rotation around the x axis in degreesroll
- the rotation around the z axis degreespublic Quaternion setEulerAnglesRad(float yaw, float pitch, float roll)
yaw
- the rotation around the y axis in radianspitch
- the rotation around the x axis in radiansroll
- the rotation around the z axis in radianspublic int getGimbalPole()
public float getRollRad()
public float getRoll()
public float getPitchRad()
public float getPitch()
public float getYawRad()
public float getYaw()
public static final float len2(float x, float y, float z, float w)
public float len2()
public Quaternion nor()
public Quaternion conjugate()
public Vector3 transform(Vector3 v)
v
- Vector to transformpublic Quaternion mul(Quaternion other)
other
- Quaternion to multiply withpublic Quaternion mul(float x, float y, float z, float w)
x
- the x component of the other quaternion to multiply withy
- the y component of the other quaternion to multiply withz
- the z component of the other quaternion to multiply withw
- the w component of the other quaternion to multiply withpublic Quaternion mulLeft(Quaternion other)
other
- Quaternion to multiply withpublic Quaternion mulLeft(float x, float y, float z, float w)
x
- the x component of the other quaternion to multiply withy
- the y component of the other quaternion to multiply withz
- the z component of the other quaternion to multiply withw
- the w component of the other quaternion to multiply withpublic Quaternion add(Quaternion quaternion)
public Quaternion add(float qx, float qy, float qz, float qw)
public void toMatrix(float[] matrix)
matrix
- Matrix to fillpublic Quaternion idt()
public boolean isIdentity()
public boolean isIdentity(float tolerance)
public Quaternion setFromAxis(Vector3 axis, float degrees)
axis
- The axisdegrees
- The angle in degreespublic Quaternion setFromAxisRad(Vector3 axis, float radians)
axis
- The axisradians
- The angle in radianspublic Quaternion setFromAxis(float x, float y, float z, float degrees)
x
- X direction of the axisy
- Y direction of the axisz
- Z direction of the axisdegrees
- The angle in degreespublic Quaternion setFromAxisRad(float x, float y, float z, float radians)
x
- X direction of the axisy
- Y direction of the axisz
- Z direction of the axisradians
- The angle in radianspublic Quaternion setFromMatrix(boolean normalizeAxes, Matrix4 matrix)
public Quaternion setFromMatrix(Matrix4 matrix)
public Quaternion setFromMatrix(boolean normalizeAxes, Matrix3 matrix)
public Quaternion setFromMatrix(Matrix3 matrix)
public Quaternion setFromAxes(float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz)
Sets the Quaternion from the given x-, y- and z-axis which have to be orthonormal.
Taken from Bones framework for JPCT, see http://www.aptalkarga.com/bones/ which in turn took it from Graphics Gem code at ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z.
xx
- x-axis x-coordinatexy
- x-axis y-coordinatexz
- x-axis z-coordinateyx
- y-axis x-coordinateyy
- y-axis y-coordinateyz
- y-axis z-coordinatezx
- z-axis x-coordinatezy
- z-axis y-coordinatezz
- z-axis z-coordinatepublic Quaternion setFromAxes(boolean normalizeAxes, float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz)
Sets the Quaternion from the given x-, y- and z-axis.
Taken from Bones framework for JPCT, see http://www.aptalkarga.com/bones/ which in turn took it from Graphics Gem code at ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z.
normalizeAxes
- whether to normalize the axes (necessary when they contain scaling)xx
- x-axis x-coordinatexy
- x-axis y-coordinatexz
- x-axis z-coordinateyx
- y-axis x-coordinateyy
- y-axis y-coordinateyz
- y-axis z-coordinatezx
- z-axis x-coordinatezy
- z-axis y-coordinatezz
- z-axis z-coordinatepublic Quaternion setFromCross(Vector3 v1, Vector3 v2)
v1
- The base vector, which should be normalized.v2
- The target vector, which should be normalized.public Quaternion setFromCross(float x1, float y1, float z1, float x2, float y2, float z2)
x1
- The base vectors x value, which should be normalized.y1
- The base vectors y value, which should be normalized.z1
- The base vectors z value, which should be normalized.x2
- The target vector x value, which should be normalized.y2
- The target vector y value, which should be normalized.z2
- The target vector z value, which should be normalized.public Quaternion slerp(Quaternion end, float alpha)
end
- the end quaternionalpha
- alpha in the range [0,1]public Quaternion slerp(Quaternion[] q)
q
- List of quaternionspublic Quaternion slerp(Quaternion[] q, float[] w)
q
- List of quaternionsw
- List of weightspublic Quaternion exp(float alpha)
alpha
- Exponentpublic static final float dot(float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2)
x1
- the x component of the first quaterniony1
- the y component of the first quaternionz1
- the z component of the first quaternionw1
- the w component of the first quaternionx2
- the x component of the second quaterniony2
- the y component of the second quaternionz2
- the z component of the second quaternionw2
- the w component of the second quaternionpublic float dot(Quaternion other)
other
- the other quaternion.public float dot(float x, float y, float z, float w)
x
- the x component of the other quaterniony
- the y component of the other quaternionz
- the z component of the other quaternionw
- the w component of the other quaternionpublic Quaternion mul(float scalar)
scalar
- the scalar.public float getAxisAngle(Vector3 axis)
axis
- vector which will receive the axispublic float getAxisAngleRad(Vector3 axis)
axis
- vector which will receive the axispublic float getAngleRad()
getAxisAngleRad(Vector3)
to get both the axis and the angle of this rotation. Use
getAngleAroundRad(Vector3)
to get the angle around a specific axis.public float getAngle()
getAxisAngle(Vector3)
to get both the axis
and the angle of this rotation. Use getAngleAround(Vector3)
to get the angle around a specific axis.public void getSwingTwist(float axisX, float axisY, float axisZ, Quaternion swing, Quaternion twist)
axisX
- the X component of the normalized axis for which to get the swing and twist rotationaxisY
- the Y component of the normalized axis for which to get the swing and twist rotationaxisZ
- the Z component of the normalized axis for which to get the swing and twist rotationswing
- will receive the swing rotation: the rotation around an axis perpendicular to the specified axistwist
- will receive the twist rotation: the rotation around the specified axispublic void getSwingTwist(Vector3 axis, Quaternion swing, Quaternion twist)
axis
- the normalized axis for which to get the swing and twist rotationswing
- will receive the swing rotation: the rotation around an axis perpendicular to the specified axistwist
- will receive the twist rotation: the rotation around the specified axispublic float getAngleAroundRad(float axisX, float axisY, float axisZ)
axisX
- the x component of the normalized axis for which to get the angleaxisY
- the y component of the normalized axis for which to get the angleaxisZ
- the z component of the normalized axis for which to get the anglepublic float getAngleAroundRad(Vector3 axis)
axis
- the normalized axis for which to get the anglepublic float getAngleAround(float axisX, float axisY, float axisZ)
axisX
- the x component of the normalized axis for which to get the angleaxisY
- the y component of the normalized axis for which to get the angleaxisZ
- the z component of the normalized axis for which to get the anglepublic float getAngleAround(Vector3 axis)
axis
- the normalized axis for which to get the angleCopyright © 2016. All rights reserved.