Rebel Fork Framework
Urho3D::Quaternion Class Reference

Rotation represented as a four-dimensional normalized vector. More...

#include <Urho3D/Math/Quaternion.h>

Public Member Functions

 Quaternion () noexcept
 Construct an identity quaternion.
 
 Quaternion (const Quaternion &quat) noexcept
 Copy-construct from another quaternion.
 
 Quaternion (float w, float x, float y, float z) noexcept
 Construct from values.
 
 Quaternion (const float data[]) noexcept
 Construct from a float array.
 
 Quaternion (float angle, const Vector3 &axis) noexcept
 Construct from an angle (in degrees) and axis.
 
 Quaternion (float angle) noexcept
 Construct from an angle (in degrees, for Urho2D).
 
 Quaternion (float x, float y, float z) noexcept
 Construct from Euler angles (in degrees). Equivalent to Y*X*Z.
 
 Quaternion (const Vector3 &angles) noexcept
 Construct from Euler angles (in degrees).
 
 Quaternion (const Vector3 &start, const Vector3 &end) noexcept
 Construct from the rotation difference between two direction vectors.
 
 Quaternion (const Vector3 &xAxis, const Vector3 &yAxis, const Vector3 &zAxis) noexcept
 Construct from orthonormal axes.
 
 Quaternion (const Matrix3 &matrix) noexcept
 Construct from a rotation matrix.
 
Quaternionoperator= (const Quaternion &rhs) noexcept
 Assign from another quaternion.
 
Quaternionoperator+= (const Quaternion &rhs)
 Add-assign a quaternion.
 
Quaternionoperator*= (float rhs)
 Multiply-assign a scalar.
 
bool operator== (const Quaternion &rhs) const
 Test for equality with another quaternion without epsilon.
 
bool operator!= (const Quaternion &rhs) const
 Test for inequality with another quaternion without epsilon.
 
Quaternion operator* (float rhs) const
 Multiply with a scalar.
 
Quaternion operator- () const
 Return negation.
 
Quaternion operator+ (const Quaternion &rhs) const
 Add a quaternion.
 
Quaternion operator- (const Quaternion &rhs) const
 Subtract a quaternion.
 
Quaternion operator* (const Quaternion &rhs) const
 Multiply a quaternion.
 
Vector3 operator* (const Vector3 &rhs) const
 Multiply a Vector3.
 
void FromAngleAxis (float angle, const Vector3 &axis)
 Define from an angle (in degrees) and axis.
 
void FromEulerAngles (float x, float y, float z)
 Define from Euler angles (in degrees). Equivalent to Y*X*Z.
 
void FromRotationTo (const Vector3 &start, const Vector3 &end)
 Define from the rotation difference between two direction vectors.
 
void FromAxes (const Vector3 &xAxis, const Vector3 &yAxis, const Vector3 &zAxis)
 Define from orthonormal axes.
 
void FromRotationMatrix (const Matrix3 &matrix)
 Define from a rotation matrix.
 
bool FromLookRotation (const Vector3 &direction, const Vector3 &up=Vector3::UP)
 Define from a direction to look in and an up direction. Return true if successful, or false if would result in a NaN, in which case the current value remains.
 
void Normalize ()
 Normalize to unit length.
 
Quaternion Normalized () const
 Return normalized to unit length.
 
Quaternion Inverse () const
 Return inverse.
 
float LengthSquared () const
 Return squared length.
 
float DotProduct (const Quaternion &rhs) const
 Calculate dot product.
 
bool Equals (const Quaternion &rhs, float eps=M_EPSILON) const
 Test for equality with another quaternion with epsilon.
 
bool Equivalent (const Quaternion &rhs, float eps=M_EPSILON) const
 Test for equivalence with another quaternion with epsilon.
 
bool IsNaN () const
 Return whether any element is NaN.
 
bool IsInf () const
 Return whether any element is Inf.
 
Quaternion Conjugate () const
 Return conjugate.
 
Vector3 EulerAngles () const
 
float YawAngle () const
 
float PitchAngle () const
 
float RollAngle () const
 
Vector3 Axis () const
 
float Angle () const
 
Vector3 AngularVelocity () const
 
Matrix3 RotationMatrix () const
 
Quaternion Slerp (const Quaternion &rhs, float t) const
 Spherical interpolation with another quaternion.
 
Quaternion Nlerp (const Quaternion &rhs, float t, bool shortestPath=false) const
 Normalized linear interpolation with another quaternion.
 
ea::pair< Quaternion, QuaternionToSwingTwist (const Vector3 &twistAxis) const
 Decompose quaternion to swing and twist components. swing * twist is the original quaternion.
 
float TwistAngle (const Vector3 &axis) const
 Return twist angle around given axis. Quaternion may or may not have additional rotation that will be ignored.
 
const float * Data () const
 Return float data.
 
ea::string ToString () const
 Return as string.
 
unsigned ToHash () const
 Return hash value for HashSet & HashMap.
 

Static Public Member Functions

static Quaternion FromAngularVelocity (const Vector3 &angularVelocity)
 

Public Attributes

float w_
 W coordinate.
 
float x_
 X coordinate.
 
float y_
 Y coordinate.
 
float z_
 Z coordinate.
 

Static Public Attributes

static const Quaternion IDENTITY
 Identity quaternion.
 
static const Quaternion ZERO { 0.0f, 0.0f, 0.0f, 0.0f }
 Zero quaternion.
 

Detailed Description

Rotation represented as a four-dimensional normalized vector.

Member Function Documentation

◆ Angle()

float Urho3D::Quaternion::Angle ( ) const

Return rotation angle.

◆ AngularVelocity()

Vector3 Urho3D::Quaternion::AngularVelocity ( ) const

Return angular velocity assuming unit time. Note: Absolute value of angular velocity is measured in radians.

◆ Axis()

Urho3D::Vector3 Urho3D::Quaternion::Axis ( ) const

Return rotation axis.

◆ EulerAngles()

Vector3 Urho3D::Quaternion::EulerAngles ( ) const

Return Euler angles in degrees.

◆ FromAngularVelocity()

Quaternion Urho3D::Quaternion::FromAngularVelocity ( const Vector3 angularVelocity)
static

Construct from angular velocity assuming unit time. Note: Absolute value of angular velocity is measured in radians.

◆ PitchAngle()

float Urho3D::Quaternion::PitchAngle ( ) const

Return pitch angle in degrees.

◆ RollAngle()

float Urho3D::Quaternion::RollAngle ( ) const

Return roll angle in degrees.

◆ RotationMatrix()

Matrix3 Urho3D::Quaternion::RotationMatrix ( ) const

Return the rotation matrix that corresponds to this quaternion.

◆ YawAngle()

float Urho3D::Quaternion::YawAngle ( ) const

Return yaw angle in degrees.


The documentation for this class was generated from the following files: