Quaternion
Inheritance: java.lang.Object
All Implemented Interfaces: com.aspose.csporter.helpers.Struct, java.io.Serializable
public final class Quaternion implements Struct<Quaternion>, Serializable
Quaternion is usually used to perform rotation in computer graphics.
Constructors
Constructor | Description |
---|---|
Quaternion(double w, double x, double y, double z) | Initializes a new instance of the Quaternion class. |
Quaternion() |
Fields
Field | Description |
---|---|
IDENTITY | The Identity quaternion. |
w | The w component. |
x | The x component. |
y | The y component. |
z | The z component. |
Methods
Method | Description |
---|---|
add(Quaternion lhs, Quaternion rhs) | Operator overloading for + |
clone() | |
concat(Quaternion rhs) | Concatenate two quaternions |
conjugate() | Returns a conjugate quaternion of current quaternion |
copyFrom(Quaternion src) | |
div(Quaternion lhs, double rhs) | Operator overloading for / |
dot(Quaternion q) | Dots product |
equals(Object obj) | Check if two quaternions equals |
eulerAngles() | Converts quaternion to rotation represented by Euler angles All components are in radian |
fromAngleAxis(double a, Vector3 axis) | Creates a quaternion around given axis and rotate in clockwise |
fromEulerAngle(Vector3 eulerAngle) | Creates quaternion from given Euler angle |
fromEulerAngle(double pitch, double yaw, double roll) | Creates quaternion from given Euler angle |
fromRotation(Vector3 orig, Vector3 dest) | Creates a quaternion that rotate from original to destination direction |
getClass() | |
getLength() | Gets the length of the quaternion |
getw() | The w component. |
getx() | The x component. |
gety() | The y component. |
getz() | The z component. |
hashCode() | Gets the hash code of Quaternion |
interpolate(float t, Quaternion from, Quaternion to) | Populates this quaternion with the interpolated value between the given quaternion arguments for a t between from and to. |
inverse() | Returns a inverse quaternion of current quaternion |
mul(Quaternion lhs, Quaternion rhs) | Operator overloading for * |
mul(Quaternion q, Vector3 v) | Operator overloading for * |
mul(Quaternion q, Vector4 v) | Operator overloading for * |
mul(Quaternion lhs, double rhs) | Operator overloading for * |
mul(Vector3 v, Quaternion q) | Operator overloading for * |
normalize() | Normalize the quaternion |
notify() | |
notifyAll() | |
op_eq(Quaternion lhs, Quaternion rhs) | Equal operator for quaternion |
op_ne(Quaternion lhs, Quaternion rhs) | Not-equal operator for quaternion |
setw(double value) | The w component. |
setx(double value) | The x component. |
sety(double value) | The y component. |
setz(double value) | The z component. |
slerp(double t, Quaternion v1, Quaternion v2) | Perform spherical linear interpolation between two values |
toAngleAxis(double[] angle, Vector3 axis) | Decompose the quaternion to angle and axis |
toMatrix() | Convert the rotation presented by quaternion to transform matrix. |
toString() | Gets the representation of quaternion in string |
wait() | |
wait(long arg0) | |
wait(long arg0, int arg1) |
Quaternion(double w, double x, double y, double z)
public Quaternion(double w, double x, double y, double z)
Initializes a new instance of the Quaternion class.
Parameters:
Parameter | Type | Description |
---|---|---|
w | double | w component of the quaternion |
x | double | x component of the quaternion |
y | double | y component of the quaternion |
z | double | z component of the quaternion |
Quaternion()
public Quaternion()
IDENTITY
public static final Quaternion IDENTITY
The Identity quaternion.
w
public double w
The w component.
x
public double x
The x component.
y
public double y
The y component.
z
public double z
The z component.
add(Quaternion lhs, Quaternion rhs)
public static Quaternion add(Quaternion lhs, Quaternion rhs)
Operator overloading for +
Parameters:
Parameter | Type | Description |
---|---|---|
lhs | Quaternion | Left quaternion |
rhs | Quaternion | Right quaternion |
Returns: Quaternion - Result quaternion
clone()
public Quaternion clone()
Returns: Quaternion
concat(Quaternion rhs)
public Quaternion concat(Quaternion rhs)
Concatenate two quaternions
Parameters:
Parameter | Type | Description |
---|---|---|
rhs | Quaternion |
Returns: Quaternion
conjugate()
public Quaternion conjugate()
Returns a conjugate quaternion of current quaternion
Returns: Quaternion - The conjugate quaternion.
copyFrom(Quaternion src)
public void copyFrom(Quaternion src)
Parameters:
Parameter | Type | Description |
---|---|---|
src | Quaternion |
div(Quaternion lhs, double rhs)
public static Quaternion div(Quaternion lhs, double rhs)
Operator overloading for /
Parameters:
Parameter | Type | Description |
---|---|---|
lhs | Quaternion | Left quaternion |
rhs | double | Right quaternion |
Returns: Quaternion - Result quaternion
dot(Quaternion q)
public double dot(Quaternion q)
Dots product
Parameters:
Parameter | Type | Description |
---|---|---|
q | Quaternion | The quaternion |
Returns: double - Dot value
equals(Object obj)
public boolean equals(Object obj)
Check if two quaternions equals
Parameters:
Parameter | Type | Description |
---|---|---|
obj | java.lang.Object | The object to check equality. |
Returns: boolean - True if all components are identically equal.
eulerAngles()
public Vector3 eulerAngles()
Converts quaternion to rotation represented by Euler angles All components are in radian
Returns: Vector3 - Result vector
fromAngleAxis(double a, Vector3 axis)
public static Quaternion fromAngleAxis(double a, Vector3 axis)
Creates a quaternion around given axis and rotate in clockwise
Parameters:
Parameter | Type | Description |
---|---|---|
a | double | Clockwise rotation in radian |
axis | Vector3 | Axis |
Returns: Quaternion - Created quaternion
fromEulerAngle(Vector3 eulerAngle)
public static Quaternion fromEulerAngle(Vector3 eulerAngle)
Creates quaternion from given Euler angle
Parameters:
Parameter | Type | Description |
---|---|---|
eulerAngle | Vector3 | Euler angle in radian |
Returns: Quaternion - Created quaternion
fromEulerAngle(double pitch, double yaw, double roll)
public static Quaternion fromEulerAngle(double pitch, double yaw, double roll)
Creates quaternion from given Euler angle
Parameters:
Parameter | Type | Description |
---|---|---|
pitch | double | Pitch in radian |
yaw | double | Yaw in radian |
roll | double | Roll in radian |
Returns: Quaternion - Created quaternion
fromRotation(Vector3 orig, Vector3 dest)
public static Quaternion fromRotation(Vector3 orig, Vector3 dest)
Creates a quaternion that rotate from original to destination direction
Parameters:
Parameter | Type | Description |
---|---|---|
orig | Vector3 | Original direction |
dest | Vector3 | Destination direction |
Returns: Quaternion - Created quaternion
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class
getLength()
public double getLength()
Gets the length of the quaternion
Returns: double
getw()
public double getw()
The w component.
Returns: double
getx()
public double getx()
The x component.
Returns: double
gety()
public double gety()
The y component.
Returns: double
getz()
public double getz()
The z component.
Returns: double
hashCode()
public int hashCode()
Gets the hash code of Quaternion
Returns: int - The hash code of the Quaternion
interpolate(float t, Quaternion from, Quaternion to)
public static Quaternion interpolate(float t, Quaternion from, Quaternion to)
Populates this quaternion with the interpolated value between the given quaternion arguments for a t between from and to.
Parameters:
Parameter | Type | Description |
---|---|---|
t | float | The coefficient to interpolate. |
from | Quaternion | Source quaternion. |
to | Quaternion | Target quaternion. |
Returns: Quaternion - The interpolated quaternion.
inverse()
public Quaternion inverse()
Returns a inverse quaternion of current quaternion
Returns: Quaternion - Inverse quaternion.
mul(Quaternion lhs, Quaternion rhs)
public static Quaternion mul(Quaternion lhs, Quaternion rhs)
Operator overloading for *
Parameters:
Parameter | Type | Description |
---|---|---|
lhs | Quaternion | Left quaternion |
rhs | Quaternion | Right quaternion |
Returns: Quaternion - Result quaternion
mul(Quaternion q, Vector3 v)
public static Vector3 mul(Quaternion q, Vector3 v)
Operator overloading for *
Parameters:
Parameter | Type | Description |
---|---|---|
q | Quaternion | The rotation quaternion |
v | Vector3 | Vector to rotate |
Returns: Vector3 - Rotated vector
mul(Quaternion q, Vector4 v)
public static Vector4 mul(Quaternion q, Vector4 v)
Operator overloading for *
Parameters:
Parameter | Type | Description |
---|---|---|
q | Quaternion | The rotation quaternion |
v | Vector4 | Vector to rotate |
Returns: Vector4 - Rotated vector
mul(Quaternion lhs, double rhs)
public static Quaternion mul(Quaternion lhs, double rhs)
Operator overloading for *
Parameters:
Parameter | Type | Description |
---|---|---|
lhs | Quaternion | Left quaternion |
rhs | double | Right quaternion |
Returns: Quaternion - Result quaternion
mul(Vector3 v, Quaternion q)
public static Vector3 mul(Vector3 v, Quaternion q)
Operator overloading for *
Parameters:
Parameter | Type | Description |
---|---|---|
v | Vector3 | The rotation quaternion |
q | Quaternion | Vector to rotate |
Returns: Vector3 - Rotated vector
normalize()
public Quaternion normalize()
Normalize the quaternion
Returns: Quaternion - Normalized quaternion.
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
op_eq(Quaternion lhs, Quaternion rhs)
public static boolean op_eq(Quaternion lhs, Quaternion rhs)
Equal operator for quaternion
Parameters:
Parameter | Type | Description |
---|---|---|
lhs | Quaternion | Left hand side value. |
rhs | Quaternion | Right hand side value. |
Returns: boolean - True if all components are identically equal.
op_ne(Quaternion lhs, Quaternion rhs)
public static boolean op_ne(Quaternion lhs, Quaternion rhs)
Not-equal operator for quaternion
Parameters:
Parameter | Type | Description |
---|---|---|
lhs | Quaternion | Left hand side value. |
rhs | Quaternion | Right hand side value. |
Returns: boolean - True if two quaternions are not equal.
setw(double value)
public void setw(double value)
The w component.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double | New value |
setx(double value)
public void setx(double value)
The x component.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double | New value |
sety(double value)
public void sety(double value)
The y component.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double | New value |
setz(double value)
public void setz(double value)
The z component.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double | New value |
slerp(double t, Quaternion v1, Quaternion v2)
public static Quaternion slerp(double t, Quaternion v1, Quaternion v2)
Perform spherical linear interpolation between two values
Parameters:
Parameter | Type | Description |
---|---|---|
t | double | t is between 0 to 1 |
v1 | Quaternion | First value |
v2 | Quaternion | Second value |
Returns: Quaternion
toAngleAxis(double[] angle, Vector3 axis)
public void toAngleAxis(double[] angle, Vector3 axis)
Decompose the quaternion to angle and axis
Parameters:
Parameter | Type | Description |
---|---|---|
angle | double[] | The angle to rotate, in radian. |
axis | Vector3 | The axis that rotates around. |
toMatrix()
public Matrix4 toMatrix()
Convert the rotation presented by quaternion to transform matrix.
Returns: Matrix4 - The matrix representation of current quaternion.
toString()
public String toString()
Gets the representation of quaternion in string
Returns: java.lang.String - Object string
wait()
public final void wait()
wait(long arg0)
public final void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |