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

ConstructorDescription
Quaternion(double w, double x, double y, double z)Initializes a new instance of the Quaternion class.
Quaternion()

Fields

FieldDescription
IDENTITYThe Identity quaternion.
wThe w component.
xThe x component.
yThe y component.
zThe z component.

Methods

MethodDescription
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:

ParameterTypeDescription
wdoublew component of the quaternion
xdoublex component of the quaternion
ydoubley component of the quaternion
zdoublez 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:

ParameterTypeDescription
lhsQuaternionLeft quaternion
rhsQuaternionRight quaternion

Returns: Quaternion - Result quaternion

clone()

public Quaternion clone()

Returns: Quaternion

concat(Quaternion rhs)

public Quaternion concat(Quaternion rhs)

Concatenate two quaternions

Parameters:

ParameterTypeDescription
rhsQuaternion

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:

ParameterTypeDescription
srcQuaternion

div(Quaternion lhs, double rhs)

public static Quaternion div(Quaternion lhs, double rhs)

Operator overloading for /

Parameters:

ParameterTypeDescription
lhsQuaternionLeft quaternion
rhsdoubleRight quaternion

Returns: Quaternion - Result quaternion

dot(Quaternion q)

public double dot(Quaternion q)

Dots product

Parameters:

ParameterTypeDescription
qQuaternionThe quaternion

Returns: double - Dot value

equals(Object obj)

public boolean equals(Object obj)

Check if two quaternions equals

Parameters:

ParameterTypeDescription
objjava.lang.ObjectThe 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:

ParameterTypeDescription
adoubleClockwise rotation in radian
axisVector3Axis

Returns: Quaternion - Created quaternion

fromEulerAngle(Vector3 eulerAngle)

public static Quaternion fromEulerAngle(Vector3 eulerAngle)

Creates quaternion from given Euler angle

Parameters:

ParameterTypeDescription
eulerAngleVector3Euler 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:

ParameterTypeDescription
pitchdoublePitch in radian
yawdoubleYaw in radian
rolldoubleRoll 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:

ParameterTypeDescription
origVector3Original direction
destVector3Destination 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:

ParameterTypeDescription
tfloatThe coefficient to interpolate.
fromQuaternionSource quaternion.
toQuaternionTarget 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:

ParameterTypeDescription
lhsQuaternionLeft quaternion
rhsQuaternionRight quaternion

Returns: Quaternion - Result quaternion

mul(Quaternion q, Vector3 v)

public static Vector3 mul(Quaternion q, Vector3 v)

Operator overloading for *

Parameters:

ParameterTypeDescription
qQuaternionThe rotation quaternion
vVector3Vector to rotate

Returns: Vector3 - Rotated vector

mul(Quaternion q, Vector4 v)

public static Vector4 mul(Quaternion q, Vector4 v)

Operator overloading for *

Parameters:

ParameterTypeDescription
qQuaternionThe rotation quaternion
vVector4Vector to rotate

Returns: Vector4 - Rotated vector

mul(Quaternion lhs, double rhs)

public static Quaternion mul(Quaternion lhs, double rhs)

Operator overloading for *

Parameters:

ParameterTypeDescription
lhsQuaternionLeft quaternion
rhsdoubleRight quaternion

Returns: Quaternion - Result quaternion

mul(Vector3 v, Quaternion q)

public static Vector3 mul(Vector3 v, Quaternion q)

Operator overloading for *

Parameters:

ParameterTypeDescription
vVector3The rotation quaternion
qQuaternionVector 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:

ParameterTypeDescription
lhsQuaternionLeft hand side value.
rhsQuaternionRight 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:

ParameterTypeDescription
lhsQuaternionLeft hand side value.
rhsQuaternionRight hand side value.

Returns: boolean - True if two quaternions are not equal.

setw(double value)

public void setw(double value)

The w component.

Parameters:

ParameterTypeDescription
valuedoubleNew value

setx(double value)

public void setx(double value)

The x component.

Parameters:

ParameterTypeDescription
valuedoubleNew value

sety(double value)

public void sety(double value)

The y component.

Parameters:

ParameterTypeDescription
valuedoubleNew value

setz(double value)

public void setz(double value)

The z component.

Parameters:

ParameterTypeDescription
valuedoubleNew 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:

ParameterTypeDescription
tdoublet is between 0 to 1
v1QuaternionFirst value
v2QuaternionSecond value

Returns: Quaternion

toAngleAxis(double[] angle, Vector3 axis)

public void toAngleAxis(double[] angle, Vector3 axis)

Decompose the quaternion to angle and axis

Parameters:

ParameterTypeDescription
angledouble[]The angle to rotate, in radian.
axisVector3The 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:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int