Tizen Native API
Dali::Quaternion Class Reference

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)
Construct from a quaternion represented by floats.
Quaternion (const Vector4 &vector)
Construct from a quaternion represented by a vector.
Quaternion (Radian angle, const Vector3 &axis)
Constructor from an axis and angle.
Construct from Euler angles.
Quaternion (const Matrix &matrix)
Construct from a matrix.
Quaternion (const Vector3 &xAxis, const Vector3 &yAxis, const Vector3 &zAxis)
Construct from 3 orthonormal axes.
Quaternion (const Vector3 &v0, const Vector3 &v1)
Construct 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
Convert the quaternion to an axis/angle pair.
const Vector4AsVector () const
Return the quaternion as a vector.
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
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)
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
Return the length of the quaternion.
float LengthSquared () const
Return the squared length of the quaternion.
void Normalize ()
Normalize this to unit length.
Quaternion Normalized () const
Normalized.
void Conjugate ()
Conjugate this quaternion.
void Invert ()
Invert 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
Rotate v by this Quaternion (Quaternion must be unit).
Vector3 Rotate (const Vector3 &vector) const
Rotate v by this Quaternion (Quaternion must be unit).

Static Public Member Functions

static float Dot (const Quaternion &q1, const Quaternion &q2)
Return 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
w component is s ( = cos(theta/2.0) )

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

Constructor & Destructor Documentation

 Dali::Quaternion::Quaternion ( )

Default Constructor.

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

Construct from a quaternion represented by floats.

Since :
2.4
Parameters:
 [in] cosThetaBy2 [in] iBySineTheta [in] jBySineTheta [in] kBySineTheta
 Dali::Quaternion::Quaternion ( const Vector4 & vector ) ` [explicit]`

Construct from a quaternion represented by a vector.

Since :
2.4
Parameters:
 [in] vector x,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
Parameters:
 [in] angle The angle around the axis [in] axis The vector of the axis

Construct from Euler angles.

Since :
2.4
Parameters:
 [in] pitch [in] yaw [in] roll
 Dali::Quaternion::Quaternion ( const Matrix & matrix ) ` [explicit]`

Construct from a matrix.

Since :
2.4
Parameters:
 [in] matrix
 Dali::Quaternion::Quaternion ( const Vector3 & xAxis, const Vector3 & yAxis, const Vector3 & zAxis ) ` [explicit]`

Construct from 3 orthonormal axes.

Since :
2.4
Parameters:
 [in] xAxis The X axis [in] yAxis The Y axis [in] zAxis The Z axis
 Dali::Quaternion::Quaternion ( const Vector3 & v0, const Vector3 & v1 ) ` [explicit]`

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

Since :
2.4
Parameters:
 [in] v0 First normalized vector [in] v1 Second normalized vector
Precondition:
v0 and v1 should be normalized
 Dali::Quaternion::~Quaternion ( )

Destructor, nonvirtual as this is not a base class.

Since :
2.4

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
Parameters:
 [in] q1 The first quaternion [in] q2 The second quaternion
Returns:
The angle between the two quaternions.
 const Vector4& Dali::Quaternion::AsVector ( ) const

Return the quaternion as a vector.

Since :
2.4
Returns:
The vector representation of the quaternion
 void Dali::Quaternion::Conjugate ( )

Conjugate this quaternion.

Since :
2.4
 static float Dali::Quaternion::Dot ( const Quaternion & q1, const Quaternion & q2 ) ` [static]`

Return the dot product of two quaternions.

Since :
2.4
Parameters:
 [in] q1 The first quaternion [in] q2 The second quaternion
Returns:
The dot product of the two quaternions
 Vector4 Dali::Quaternion::EulerAngles ( ) const

returns the Euler angles from a rotation Quaternion.

Since :
2.4
Returns:
A vector of Euler angles (x == pitch, y == yaw, z == roll)
 Quaternion Dali::Quaternion::Exp ( ) const

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

Since :
2.4
Returns:
A quaternion representing the exponent
 void Dali::Quaternion::Invert ( )

Invert this quaternion.

Since :
2.4
 bool Dali::Quaternion::IsIdentity ( ) const

Helper to check if this is an identity quaternion.

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

Return the length of the quaternion.

Since :
2.4
Returns:
The length of the quaternion
 float Dali::Quaternion::LengthSquared ( ) const

Return the squared length of the quaternion.

Since :
2.4
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
Parameters:
 [in] q1 The start quaternion [in] q2 The end quaternion [in] t A progress value between 0 and 1
Returns:
The interpolated quaternion
 Quaternion Dali::Quaternion::Log ( ) const

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

Since :
2.4
Returns:
A quaternion representing the logarithm
 void Dali::Quaternion::Normalize ( )

Normalize this to unit length.

Since :
2.4
 Quaternion Dali::Quaternion::Normalized ( ) const

Normalized.

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

Inequality operator.

Since :
2.4
Parameters:
 [in] rhs The quaterion 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
Parameters:
 [in] other The quaternion to multiply
Returns:
A quaternion containing the result
 Vector3 Dali::Quaternion::operator* ( const Vector3 & other ) const

Multiplication operator.

Since :
2.4
Parameters:
 [in] other The 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
Parameters:
 [in] scale A 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
Parameters:
 [in] other The quaternion to multiply
Returns:
A reference to this
 const Quaternion& Dali::Quaternion::operator*= ( float scale )

Scale with Assignment operator.

Since :
2.4
Parameters:
 [in] scale the value to scale by
Returns:
A reference to this
 const Quaternion Dali::Quaternion::operator+ ( const Quaternion & other ) const

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

Since :
2.4
Parameters:
 [in] other The quaternion to add
Returns:
A reference to this
 const Quaternion Dali::Quaternion::operator- ( const Quaternion & other ) const

Subtraction operator.

Since :
2.4
Parameters:
 [in] other The quaternion to subtract
Returns:
A quaternion containing the result of the subtract
 Quaternion Dali::Quaternion::operator- ( ) const

Unary Negation operator.

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

Subtraction with Assignment operator.

Since :
2.4
Parameters:
 [in] other The quaternion to subtract
Returns:
A reference to this
 const Quaternion Dali::Quaternion::operator/ ( const Quaternion & other ) const

Division operator.

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

Scale operator.

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

Scale with Assignment operator.

Since :
2.4
Parameters:
 [in] scale The value to scale by
Returns:
A reference to this
 bool Dali::Quaternion::operator== ( const Quaternion & rhs ) const

Equality operator.

Since :
2.4
Parameters:
 [in] rhs The quaterion to compare with.
Returns:
True if the quaternions are equal.
 Vector4 Dali::Quaternion::Rotate ( const Vector4 & vector ) const

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

Since :
2.4
Parameters:
 [in] vector A vector to rotate
Returns:
The rotated vector
 Vector3 Dali::Quaternion::Rotate ( const Vector3 & vector ) const

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

Since :
2.4
Parameters:
 [in] vector A vector to rotate
Returns:
The rotated vector

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

Since :
2.4
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
Parameters:
 [in] q1 The start quaternion [in] q2 The end quaternion [in] progress A 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
Parameters:
 [in] q1 The start quaternion [in] q2 The end quaternion [in] t A 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
Parameters:
 [in] start The start quaternion [in] end The end quaternion [in] ctrl1 The control quaternion for q1 [in] ctrl2 The control quaternion for q2 [in] t A progress value between 0 and 1
Returns:
The interpolated quaternion
 bool Dali::Quaternion::ToAxisAngle ( Vector3 & axis, Radian & angle ) const

Convert the quaternion to an axis/angle pair.

Since :
2.4
Parameters:
 [out] axis [out] angle Angle in radians
Returns:
True if converted correctly