Tizen Native API
5.0
|
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 Vector4 & | AsVector () 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 Quaternion & | operator+= (const Quaternion &other) |
Addition with Assignment operator. | |
const Quaternion & | operator-= (const Quaternion &other) |
Subtraction with Assignment operator. | |
const Quaternion & | operator*= (const Quaternion &other) |
Multiplication with Assignment operator. | |
const Quaternion & | operator*= (float scale) |
Scale with Assignment operator. | |
const Quaternion & | operator/= (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:
- 3.0, DALi version 1.0.0
Constructor & Destructor Documentation
Default Constructor.
- Since:
- 3.0, DALi version 1.0.0
Dali::Quaternion::Quaternion | ( | float | cosThetaBy2, |
float | iBySineTheta, | ||
float | jBySineTheta, | ||
float | kBySineTheta | ||
) |
Constructs from a quaternion represented by floats.
- Since:
- 3.0, 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:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] angle The angle around the axis [in] axis The vector of the axis
Dali::Quaternion::Quaternion | ( | Radian | pitch, |
Radian | yaw, | ||
Radian | roll | ||
) |
Constructs from Euler angles.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] pitch [in] yaw [in] roll
Dali::Quaternion::Quaternion | ( | const Matrix & | matrix | ) | [explicit] |
Constructs from a matrix.
- Since:
- 3.0, 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:
- 3.0, DALi version 1.0.0
- 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] |
Constructs quaternion which describes minimum rotation to align v0 with v1.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] v0 First normalized vector [in] v1 Second normalized vector
- Precondition:
- v0 and v1 should be normalized
Destructor, nonvirtual as this is not a base class.
- Since:
- 3.0, 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:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] q1 The first quaternion [in] q2 The second quaternion
- Returns:
- The angle between the two quaternions
const Vector4& Dali::Quaternion::AsVector | ( | ) | const |
Returns the quaternion as a vector.
- Since:
- 3.0, DALi version 1.0.0
- Returns:
- The vector representation of the quaternion
void Dali::Quaternion::Conjugate | ( | ) |
Conjugates this quaternion.
- Since:
- 3.0, 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:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, DALi version 1.0.0
- Returns:
- A quaternion representing the exponent
void Dali::Quaternion::Invert | ( | ) |
Inverts this quaternion.
- Since:
- 3.0, DALi version 1.0.0
bool Dali::Quaternion::IsIdentity | ( | ) | const |
Helper to check if this is an identity quaternion.
- Since:
- 3.0, DALi version 1.0.0
- Returns:
- True if this is identity quaternion
float Dali::Quaternion::Length | ( | ) | const |
Returns the length of the quaternion.
- Since:
- 3.0, DALi version 1.0.0
- Returns:
- The length of the quaternion
float Dali::Quaternion::LengthSquared | ( | ) | const |
Returns the squared length of the quaternion.
- Since:
- 3.0, 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:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, DALi version 1.0.0
- Returns:
- A quaternion representing the logarithm
void Dali::Quaternion::Normalize | ( | ) |
Normalizes this to unit length.
- Since:
- 3.0, DALi version 1.0.0
Quaternion Dali::Quaternion::Normalized | ( | ) | const |
Normalized.
- Since:
- 3.0, DALi version 1.0.0
- Returns:
- A normalized version of this quaternion
bool Dali::Quaternion::operator!= | ( | const Quaternion & | rhs | ) | const |
Inequality operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The quaternion to compare with
- Returns:
- True if the quaternions are not equal
const Quaternion Dali::Quaternion::operator* | ( | const Quaternion & | other | ) | const |
Multiplication operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] other The quaternion to multiply
- Returns:
- A quaternion containing the result
Multiplication operator.
- Since:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] other The quaternion to multiply
- Returns:
- A reference to this
const Quaternion& Dali::Quaternion::operator*= | ( | float | scale | ) |
Scale with Assignment operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] scale the value to scale by
- Returns:
- A reference to this
const Quaternion Dali::Quaternion::operator+ | ( | const Quaternion & | other | ) | const |
Addition operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] other The 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:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] other The quaternion to add
- Returns:
- A reference to this
const Quaternion Dali::Quaternion::operator- | ( | const Quaternion & | other | ) | const |
Subtraction operator.
- Since:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, 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:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] other The quaternion to subtract
- Returns:
- A reference to this
const Quaternion Dali::Quaternion::operator/ | ( | const Quaternion & | other | ) | const |
Division operator.
- Since:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] scale The value to scale by
- Returns:
- A reference to this
bool Dali::Quaternion::operator== | ( | const Quaternion & | rhs | ) | const |
Equality operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The 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:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] vector A 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:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] vector A 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:
- 3.0, 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:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, DALi version 1.0.0
- 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:
- 3.0, DALi version 1.0.0
- 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 |
Converts the quaternion to an axis/angle pair.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[out] axis [out] angle Angle in radians
- Returns:
- True if converted correctly
Member Data Documentation
w component is s ( = cos(theta/2.0) )