Tizen(Headed) Native API  6.5

The Quaternion class encapsulates the mathematics of the quaternion. More...

Public Member Functions

 Quaternion ()
 Default Constructor.
 Quaternion (float cosThetaBy2, float iBySineTheta, float jBySineTheta, float kBySineTheta)
 Constructs from a quaternion represented by floats.
 Quaternion (const Vector4 &vector)
 Constructs from a quaternion represented by a vector.
 Quaternion (Radian angle, const Vector3 &axis)
 Constructor from an axis and angle.
 Quaternion (Radian pitch, Radian yaw, Radian roll)
 Constructs from Euler angles.
 Quaternion (const Matrix &matrix)
 Constructs from a matrix.
 Quaternion (const Vector3 &xAxis, const Vector3 &yAxis, const Vector3 &zAxis)
 Constructs from 3 orthonormal axes.
 Quaternion (const Vector3 &v0, const Vector3 &v1)
 Constructs quaternion which describes minimum rotation to align v0 with v1.
 ~Quaternion ()
 Destructor, nonvirtual as this is not a base class.
bool IsIdentity () const
 Helper to check if this is an identity quaternion.
bool ToAxisAngle (Vector3 &axis, Radian &angle) const
 Converts the quaternion to an axis/angle pair.
const Vector4AsVector () const
 Returns the quaternion as a vector.
void SetEuler (Radian pitch, Radian yaw, Radian roll)
 SetEuler sets the quaternion from the Euler angles applied in x, y, z order.
Vector4 EulerAngles () const
 Returns the Euler angles from a rotation Quaternion.
const Quaternion operator+ (const Quaternion &other) const
 Addition operator.
const Quaternion operator- (const Quaternion &other) const
 Subtraction operator.
const Quaternion operator* (const Quaternion &other) const
 Multiplication operator.
Vector3 operator* (const Vector3 &other) const
 Multiplication operator.
const Quaternion operator/ (const Quaternion &other) const
 Division operator.
const Quaternion operator* (float scale) const
 Scale operator.
const Quaternion operator/ (float scale) const
 Scale operator.
Quaternion operator- () const
 Unary Negation operator.
const Quaternionoperator+= (const Quaternion &other)
 Addition with Assignment operator.
const Quaternionoperator-= (const Quaternion &other)
 Subtraction with Assignment operator.
const Quaternionoperator*= (const Quaternion &other)
 Multiplication with Assignment operator.
const Quaternionoperator*= (float scale)
 Scale with Assignment operator.
const Quaternionoperator/= (float scale)
 Scale with Assignment operator.
bool operator== (const Quaternion &rhs) const
 Equality operator.
bool operator!= (const Quaternion &rhs) const
 Inequality operator.
float Length () const
 Returns the length of the quaternion.
float LengthSquared () const
 Returns the squared length of the quaternion.
void Normalize ()
 Normalizes this to unit length.
Quaternion Normalized () const
 Normalized.
void Conjugate ()
 Conjugates this quaternion.
void Invert ()
 Inverts this quaternion.
Quaternion Log () const
 Performs the logarithm of a Quaternion = v*a where q = (cos(a),v*sin(a)).
Quaternion Exp () const
 Performs an exponent e^Quaternion = Exp(v*a) = (cos(a),vsin(a)).
Vector4 Rotate (const Vector4 &vector) const
 Rotates v by this Quaternion (Quaternion must be unit).
Vector3 Rotate (const Vector3 &vector) const
 Rotates v by this Quaternion (Quaternion must be unit).

Static Public Member Functions

static float Dot (const Quaternion &q1, const Quaternion &q2)
 Returns the dot product of two quaternions.
static Quaternion Lerp (const Quaternion &q1, const Quaternion &q2, float t)
 Linear Interpolation (using a straight line between the two quaternions).
static Quaternion Slerp (const Quaternion &q1, const Quaternion &q2, float progress)
 Spherical Linear Interpolation (using the shortest arc of a great circle between the two quaternions).
static Quaternion SlerpNoInvert (const Quaternion &q1, const Quaternion &q2, float t)
 This version of Slerp, used by Squad, does not check for theta > 90.
static Quaternion Squad (const Quaternion &start, const Quaternion &end, const Quaternion &ctrl1, const Quaternion &ctrl2, float t)
 Spherical Cubic Interpolation.
static float AngleBetween (const Quaternion &q1, const Quaternion &q2)
 Returns the shortest angle between two quaternions in Radians.

Public Attributes

Vector4 mVector

Static Public Attributes

static const Quaternion IDENTITY
 (0.0f,0.0f,0.0f,1.0f)

Detailed Description

The Quaternion class encapsulates the mathematics of the quaternion.

Since:
2.4, DALi version 1.0.0

Constructor & Destructor Documentation

Default Constructor.

Since:
2.4, DALi version 1.0.0
Dali::Quaternion::Quaternion ( float  cosThetaBy2,
float  iBySineTheta,
float  jBySineTheta,
float  kBySineTheta 
)

Constructs from a quaternion represented by floats.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]cosThetaBy2
[in]iBySineTheta
[in]jBySineTheta
[in]kBySineTheta
Dali::Quaternion::Quaternion ( const Vector4 vector) [explicit]

Constructs from a quaternion represented by a vector.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]vectorx,y,z fields represent i,j,k coefficients, w represents cos(theta/2)
Dali::Quaternion::Quaternion ( Radian  angle,
const Vector3 axis 
)

Constructor from an axis and angle.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]angleThe angle around the axis
[in]axisThe vector of the axis
Dali::Quaternion::Quaternion ( Radian  pitch,
Radian  yaw,
Radian  roll 
)

Constructs from Euler angles.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]pitch
[in]yaw
[in]roll
Dali::Quaternion::Quaternion ( const Matrix matrix) [explicit]

Constructs from a matrix.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]matrix
Dali::Quaternion::Quaternion ( const Vector3 xAxis,
const Vector3 yAxis,
const Vector3 zAxis 
) [explicit]

Constructs from 3 orthonormal axes.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]xAxisThe X axis
[in]yAxisThe Y axis
[in]zAxisThe Z axis
Dali::Quaternion::Quaternion ( const Vector3 v0,
const Vector3 v1 
) [explicit]

Constructs quaternion which describes minimum rotation to align v0 with v1.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]v0First normalized vector
[in]v1Second normalized vector
Precondition:
v0 and v1 should be normalized

Destructor, nonvirtual as this is not a base class.

Since:
2.4, DALi version 1.0.0

Member Function Documentation

static float Dali::Quaternion::AngleBetween ( const Quaternion q1,
const Quaternion q2 
) [static]

Returns the shortest angle between two quaternions in Radians.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]q1The first quaternion
[in]q2The second quaternion
Returns:
The angle between the two quaternions

Returns the quaternion as a vector.

Since:
2.4, DALi version 1.0.0
Returns:
The vector representation of the quaternion

Conjugates this quaternion.

Since:
2.4, DALi version 1.0.0
static float Dali::Quaternion::Dot ( const Quaternion q1,
const Quaternion q2 
) [static]

Returns the dot product of two quaternions.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]q1The first quaternion
[in]q2The second quaternion
Returns:
The dot product of the two quaternions

Returns the Euler angles from a rotation Quaternion.

Since:
2.4, DALi version 1.0.0
Returns:
A vector of Euler angles (x == pitch, y == yaw, z == roll)

Performs an exponent e^Quaternion = Exp(v*a) = (cos(a),vsin(a)).

Since:
2.4, DALi version 1.0.0
Returns:
A quaternion representing the exponent

Inverts this quaternion.

Since:
2.4, DALi version 1.0.0

Helper to check if this is an identity quaternion.

Since:
2.4, DALi version 1.0.0
Returns:
True if this is identity quaternion
float Dali::Quaternion::Length ( ) const

Returns the length of the quaternion.

Since:
2.4, DALi version 1.0.0
Returns:
The length of the quaternion

Returns the squared length of the quaternion.

Since:
2.4, DALi version 1.0.0
Returns:
The squared length of the quaternion
static Quaternion Dali::Quaternion::Lerp ( const Quaternion q1,
const Quaternion q2,
float  t 
) [static]

Linear Interpolation (using a straight line between the two quaternions).

Since:
2.4, DALi version 1.0.0
Parameters:
[in]q1The start quaternion
[in]q2The end quaternion
[in]tA progress value between 0 and 1
Returns:
The interpolated quaternion

Performs the logarithm of a Quaternion = v*a where q = (cos(a),v*sin(a)).

Since:
2.4, DALi version 1.0.0
Returns:
A quaternion representing the logarithm

Normalizes this to unit length.

Since:
2.4, DALi version 1.0.0

Normalized.

Since:
2.4, DALi version 1.0.0
Returns:
A normalized version of this quaternion
bool Dali::Quaternion::operator!= ( const Quaternion rhs) const

Inequality operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]rhsThe quaternion to compare with
Returns:
True if the quaternions are not equal
const Quaternion Dali::Quaternion::operator* ( const Quaternion other) const

Multiplication operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]otherThe quaternion to multiply
Returns:
A quaternion containing the result
Vector3 Dali::Quaternion::operator* ( const Vector3 other) const

Multiplication operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]otherThe vector to multiply
Returns:
A vector containing the result of the multiplication
const Quaternion Dali::Quaternion::operator* ( float  scale) const

Scale operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]scaleA value to scale by
Returns:
A quaternion containing the result
const Quaternion& Dali::Quaternion::operator*= ( const Quaternion other)

Multiplication with Assignment operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]otherThe quaternion to multiply
Returns:
A reference to this
const Quaternion& Dali::Quaternion::operator*= ( float  scale)

Scale with Assignment operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]scalethe value to scale by
Returns:
A reference to this
const Quaternion Dali::Quaternion::operator+ ( const Quaternion other) const

Addition operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]otherThe quaternion to add
Returns:
A quaternion containing the result of the addition
const Quaternion& Dali::Quaternion::operator+= ( const Quaternion other)

Addition with Assignment operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]otherThe quaternion to add
Returns:
A reference to this
const Quaternion Dali::Quaternion::operator- ( const Quaternion other) const

Subtraction operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]otherThe quaternion to subtract
Returns:
A quaternion containing the result of the subtract
Quaternion Dali::Quaternion::operator- ( ) const

Unary Negation operator.

Since:
2.4, DALi version 1.0.0
Returns:
A quaternion containing the negated result
const Quaternion& Dali::Quaternion::operator-= ( const Quaternion other)

Subtraction with Assignment operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]otherThe quaternion to subtract
Returns:
A reference to this
const Quaternion Dali::Quaternion::operator/ ( const Quaternion other) const

Division operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]otherA quaternion to divide by
Returns:
A quaternion containing the result
const Quaternion Dali::Quaternion::operator/ ( float  scale) const

Scale operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]scaleA value to scale by
Returns:
A quaternion containing the result
const Quaternion& Dali::Quaternion::operator/= ( float  scale)

Scale with Assignment operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]scaleThe value to scale by
Returns:
A reference to this
bool Dali::Quaternion::operator== ( const Quaternion rhs) const

Equality operator.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]rhsThe quaternion to compare with
Returns:
True if the quaternions are equal
Vector4 Dali::Quaternion::Rotate ( const Vector4 vector) const

Rotates v by this Quaternion (Quaternion must be unit).

Since:
2.4, DALi version 1.0.0
Parameters:
[in]vectorA vector to rotate
Returns:
The rotated vector
Vector3 Dali::Quaternion::Rotate ( const Vector3 vector) const

Rotates v by this Quaternion (Quaternion must be unit).

Since:
2.4, DALi version 1.0.0
Parameters:
[in]vectorA vector to rotate
Returns:
The rotated vector
void Dali::Quaternion::SetEuler ( Radian  pitch,
Radian  yaw,
Radian  roll 
)

SetEuler sets the quaternion from the Euler angles applied in x, y, z order.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]pitch
[in]yaw
[in]roll
static Quaternion Dali::Quaternion::Slerp ( const Quaternion q1,
const Quaternion q2,
float  progress 
) [static]

Spherical Linear Interpolation (using the shortest arc of a great circle between the two quaternions).

Since:
2.4, DALi version 1.0.0
Parameters:
[in]q1The start quaternion
[in]q2The end quaternion
[in]progressA progress value between 0 and 1
Returns:
The interpolated quaternion
static Quaternion Dali::Quaternion::SlerpNoInvert ( const Quaternion q1,
const Quaternion q2,
float  t 
) [static]

This version of Slerp, used by Squad, does not check for theta > 90.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]q1The start quaternion
[in]q2The end quaternion
[in]tA progress value between 0 and 1
Returns:
The interpolated quaternion
static Quaternion Dali::Quaternion::Squad ( const Quaternion start,
const Quaternion end,
const Quaternion ctrl1,
const Quaternion ctrl2,
float  t 
) [static]

Spherical Cubic Interpolation.

Since:
2.4, DALi version 1.0.0
Parameters:
[in]startThe start quaternion
[in]endThe end quaternion
[in]ctrl1The control quaternion for q1
[in]ctrl2The control quaternion for q2
[in]tA progress value between 0 and 1
Returns:
The interpolated quaternion
bool Dali::Quaternion::ToAxisAngle ( Vector3 axis,
Radian angle 
) const

Converts the quaternion to an axis/angle pair.

Since:
2.4, DALi version 1.0.0
Parameters:
[out]axis
[out]angleAngle in radians
Returns:
True if converted correctly

Member Data Documentation

w component is s ( = cos(theta/2.0) )