Package com.aspose.threed
Class Quaternion
- java.lang.Object
-
- com.aspose.threed.Quaternion
-
- All Implemented Interfaces:
com.aspose.threed.Struct<Quaternion>
,java.io.Serializable
,java.lang.Cloneable
public final class Quaternion extends java.lang.Object implements com.aspose.threed.Struct<Quaternion>, java.io.Serializable
Quaternion is usually used to perform rotation in computer graphics.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Quaternion()
Quaternion(double w, double x, double y, double z)
Initializes a new instance of theQuaternion
class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Quaternion
add(Quaternion lhs, Quaternion rhs)
Operator overloading for +Quaternion
clone()
Quaternion
concat(Quaternion rhs)
Concatenate two quaternionsQuaternion
conjugate()
Returns a conjugate quaternion of current quaternionvoid
copyFrom(Quaternion src)
static Quaternion
div(Quaternion lhs, double rhs)
Operator overloading for /double
dot(Quaternion q)
Dots productboolean
equals(java.lang.Object obj)
Check if two quaternions equalsVector3
eulerAngles()
Converts quaternion to rotation represented by Euler angles All components are in radianstatic Quaternion
fromAngleAxis(double a, Vector3 axis)
Creates a quaternion around given axis and rotate in clockwisestatic Quaternion
fromEulerAngle(double pitch, double yaw, double roll)
Creates quaternion from given Euler anglestatic Quaternion
fromEulerAngle(Vector3 eulerAngle)
Creates quaternion from given Euler anglestatic Quaternion
fromRotation(Vector3 orig, Vector3 dest)
Creates a quaternion that rotate from original to destination directiondouble
getLength()
Gets the length of the quaternionint
hashCode()
Gets the hash code of Quaternionstatic 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.Quaternion
inverse()
Returns a inverse quaternion of current quaternionstatic Quaternion
mul(Quaternion lhs, double rhs)
Operator overloading for *static Quaternion
mul(Quaternion lhs, Quaternion rhs)
Operator overloading for *static Vector3
mul(Quaternion q, Vector3 v)
Operator overloading for *static Vector4
mul(Quaternion q, Vector4 v)
Operator overloading for *static Vector3
mul(Vector3 v, Quaternion q)
Operator overloading for *Quaternion
normalize()
Normalize the quaternionstatic boolean
op_eq(Quaternion lhs, Quaternion rhs)
Equal operator for quaternionstatic boolean
op_ne(Quaternion lhs, Quaternion rhs)
Not-equal operator for quaternionvoid
toAngleAxis(double[] angle, Vector3 axis)
Decompose the quaternion to angle and axisMatrix4
toMatrix()
Convert the rotation presented by quaternion to transform matrix.java.lang.String
toString()
Gets the representation of quaternion in string
-
-
-
Field Detail
-
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.
-
-
Constructor Detail
-
Quaternion
public Quaternion(double w, double x, double y, double z)
Initializes a new instance of theQuaternion
class.- Parameters:
w
- w component of the quaternionx
- x component of the quaterniony
- y component of the quaternionz
- z component of the quaternion
-
Quaternion
public Quaternion()
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
Check if two quaternions equals- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- The object to check equality.- Returns:
- True if all components are identically equal.
-
conjugate
public Quaternion conjugate()
Returns a conjugate quaternion of current quaternion- Returns:
- The conjugate quaternion.
-
inverse
public Quaternion inverse()
Returns a inverse quaternion of current quaternion- Returns:
- Inverse quaternion.
-
dot
public double dot(Quaternion q)
Dots product- Parameters:
q
- The quaternion- Returns:
- Dot value
-
eulerAngles
public Vector3 eulerAngles()
Converts quaternion to rotation represented by Euler angles All components are in radian- Returns:
- Result vector
-
getLength
public double getLength()
Gets the length of the quaternion
-
normalize
public Quaternion normalize()
Normalize the quaternion- Returns:
- Normalized quaternion.
-
toAngleAxis
public void toAngleAxis(double[] angle, Vector3 axis)
Decompose the quaternion to angle and axis- Parameters:
angle
- The angle to rotate, in radian.axis
- The axis that rotates around.
-
concat
public Quaternion concat(Quaternion rhs)
Concatenate two quaternions- Parameters:
rhs
-
-
fromAngleAxis
public static Quaternion fromAngleAxis(double a, Vector3 axis)
Creates a quaternion around given axis and rotate in clockwise- Parameters:
a
- Clockwise rotation in radianaxis
- Axis- Returns:
- Created quaternion
-
fromRotation
public static Quaternion fromRotation(Vector3 orig, Vector3 dest)
Creates a quaternion that rotate from original to destination direction- Parameters:
orig
- Original directiondest
- Destination direction- Returns:
- Created quaternion
-
fromEulerAngle
public static Quaternion fromEulerAngle(double pitch, double yaw, double roll)
Creates quaternion from given Euler angle- Parameters:
pitch
- Pitch in radianyaw
- Yaw in radianroll
- Roll in radian- Returns:
- Created quaternion
-
fromEulerAngle
public static Quaternion fromEulerAngle(Vector3 eulerAngle)
Creates quaternion from given Euler angle- Parameters:
eulerAngle
- Euler angle in radian- Returns:
- Created quaternion
-
toMatrix
public Matrix4 toMatrix()
Convert the rotation presented by quaternion to transform matrix.- Returns:
- The matrix representation of current quaternion.
-
add
public static Quaternion add(Quaternion lhs, Quaternion rhs)
Operator overloading for +- Parameters:
lhs
- Left quaternionrhs
- Right quaternion- Returns:
- Result quaternion
-
div
public static Quaternion div(Quaternion lhs, double rhs)
Operator overloading for /- Parameters:
lhs
- Left quaternionrhs
- Right quaternion- Returns:
- Result quaternion
-
mul
public static Quaternion mul(Quaternion lhs, double rhs)
Operator overloading for *- Parameters:
lhs
- Left quaternionrhs
- Right quaternion- Returns:
- Result quaternion
-
mul
public static Quaternion mul(Quaternion lhs, Quaternion rhs)
Operator overloading for *- Parameters:
lhs
- Left quaternionrhs
- Right quaternion- Returns:
- Result quaternion
-
mul
public static Vector3 mul(Quaternion q, Vector3 v)
Operator overloading for *- Parameters:
q
- The rotation quaternionv
- Vector to rotate- Returns:
- Rotated vector
-
mul
public static Vector4 mul(Quaternion q, Vector4 v)
Operator overloading for *- Parameters:
q
- The rotation quaternionv
- Vector to rotate- Returns:
- Rotated vector
-
toString
public java.lang.String toString()
Gets the representation of quaternion in string- Overrides:
toString
in classjava.lang.Object
- Returns:
- Object string
-
mul
public static Vector3 mul(Vector3 v, Quaternion q)
Operator overloading for *- Parameters:
v
- The rotation quaternionq
- Vector to rotate- Returns:
- Rotated vector
-
op_eq
public static boolean op_eq(Quaternion lhs, Quaternion rhs)
Equal operator for quaternion- Parameters:
lhs
- Left hand side value.rhs
- Right hand side value.- Returns:
- True if all components are identically equal.
-
op_ne
public static boolean op_ne(Quaternion lhs, Quaternion rhs)
Not-equal operator for quaternion- Parameters:
lhs
- Left hand side value.rhs
- Right hand side value.- Returns:
- True if two quaternions are not equal.
-
interpolate
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:
t
- The coefficient to interpolate.from
- Source quaternion.to
- Target quaternion.- Returns:
- The interpolated quaternion.
-
clone
public Quaternion clone()
- Specified by:
clone
in interfacecom.aspose.threed.Struct<Quaternion>
- Overrides:
clone
in classjava.lang.Object
-
copyFrom
public void copyFrom(Quaternion src)
- Specified by:
copyFrom
in interfacecom.aspose.threed.Struct<Quaternion>
-
hashCode
public int hashCode()
Gets the hash code of Quaternion- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hash code of the
Quaternion
-
-