template<typename T>
Quaternion class
| Template parameters | |
|---|---|
| T | the number type |
Contents
Represents a quaternion
Public static variables
- static const Quaternion<T> Zero
- static const Quaternion<T> Identity
Public static functions
- static auto Lerp(const Quaternion<T>& q, const Quaternion<T>& q1, T t) -> Quaternion<T>
- static auto Slerp(const Quaternion<T>& q, const Quaternion<T>& q1, T t) -> Quaternion<T>
- static auto LookAt(const Vector3<T>& dir, const Vector3<T>& forward = Vector3<T>::Forward, const Vector3<T>& up = Vector3<T>::Up) -> Quaternion<T>
Constructors, destructors, conversion operators
- Quaternion()
- Quaternion(const T w, const T i, const T j, const T k)
- Quaternion(const Vector<T, 3>& euler) explicit
- Quaternion(const Vector<T, 3>& from, const Vector<T, 3>& to)
- Quaternion(const Vector<T, 3>& axis, T ang)
Public functions
- auto Rotate(const Vector<T, 3>& v) const -> Vector<T, 3>
- auto Up() const -> Vector<T, 3>
- auto Forward() const -> Vector<T, 3>
- auto Right() const -> Vector<T, 3>
- auto ToMatrix() const -> Matrix<T, 4, 4>
- auto Inverse() const -> Quaternion<T>
- auto Norm() const -> T noexcept
- auto Normalize() const -> Quaternion<T> noexcept
- auto operator==(const Quaternion<T>& other) const -> bool
- auto operator!=(const Quaternion<T>& other) const -> bool
- auto operator*(const Quaternion<T>& other) const -> Quaternion<T>
- auto operator*(const T& other) const -> Quaternion<T>
- auto operator+(const Quaternion<T>& other) const -> Quaternion<T>
- auto operator-(const Quaternion<T>& other) const -> Quaternion<T>
- auto Dot(const Quaternion<T>& other) const -> T
- auto Angle(const Quaternion<T>& other) const -> T
- auto ToEulerAngles() const -> Vector<T, 3>
Public variables
Function documentation
template<typename T>
static Quaternion<T> bpf:: math:: Quaternion<T>:: Lerp(const Quaternion<T>& q,
const Quaternion<T>& q1,
T t)
| Parameters | |
|---|---|
| q | first quaternion |
| q1 | second quaternion |
| t | interpolation factor |
| Returns | new quaternion |
Performs linear interpolation between two quaternions
template<typename T>
static Quaternion<T> bpf:: math:: Quaternion<T>:: Slerp(const Quaternion<T>& q,
const Quaternion<T>& q1,
T t)
| Parameters | |
|---|---|
| q | first quaternion |
| q1 | second quaternion |
| t | interpolation factor |
| Returns | new quaternion |
Performs spherical linear interpolation between two quaternions
template<typename T>
static Quaternion<T> bpf:: math:: Quaternion<T>:: LookAt(const Vector3<T>& dir,
const Vector3<T>& forward = Vector3<T>::Forward,
const Vector3<T>& up = Vector3<T>::Up)
| Parameters | |
|---|---|
| dir | the direction to look at |
| forward | the world's forward vector |
| up | the world's up vector |
| Returns | new quaternion |
Computes a quaternion to point a vector in a given direction
template<typename T>
bpf:: math:: Quaternion<T>:: Quaternion()
Constructs an empty quaternion
template<typename T>
bpf:: math:: Quaternion<T>:: Quaternion(const T w,
const T i,
const T j,
const T k)
| Parameters | |
|---|---|
| w | real component |
| i | imaginary I component |
| j | imaginary J component |
| k | imaginary K component |
Constructs a quaternion from individual components
template<typename T>
bpf:: math:: Quaternion<T>:: Quaternion(const Vector<T, 3>& euler) explicit
| Parameters | |
|---|---|
| euler | euler angles X = Pitch, Y = Yaw, Z = Roll |
Constructs a quaternion from euler angles WARNING : Angles are expressed in radians
template<typename T>
bpf:: math:: Quaternion<T>:: Quaternion(const Vector<T, 3>& from,
const Vector<T, 3>& to)
| Parameters | |
|---|---|
| from | first vector |
| to | second vector |
Constructs a quaternion from the rotation between two vectors
template<typename T>
bpf:: math:: Quaternion<T>:: Quaternion(const Vector<T, 3>& axis,
T ang)
| Parameters | |
|---|---|
| axis | the rotation axis |
| ang | the rotation angle |
Constructs a quaternion from axis angle WARNING : Angle is expressed in radians
template<typename T>
Vector<T, 3> bpf:: math:: Quaternion<T>:: Up() const
| Returns | up vector from rotation of Vector3<T>:: |
|---|
Computes an Up vector by rotating the Framework's default up vector by this quaternion
template<typename T>
Vector<T, 3> bpf:: math:: Quaternion<T>:: Forward() const
| Returns | forward vector from rotation of Vector3<T>:: |
|---|
Computes a Forward vector by rotating the Framework's default forward vector by this quaternion
template<typename T>
Vector<T, 3> bpf:: math:: Quaternion<T>:: Right() const
| Returns | right vector from rotation of Vector3<T>:: |
|---|
Computes a Right vector by rotating the Framework's default right vector by this quaternion
template<typename T>
Quaternion<T> bpf:: math:: Quaternion<T>:: Inverse() const
| Returns | new quaternion |
|---|
Computes the inverse of this quaternion
template<typename T>
T bpf:: math:: Quaternion<T>:: Norm() const noexcept
| Returns | number |
|---|
Computes the norm of this quaternion
template<typename T>
Quaternion<T> bpf:: math:: Quaternion<T>:: Normalize() const noexcept
| Returns | new unit quaternion |
|---|
Normalizes this quaternion to a unit quaternion
template<typename T>
bool bpf:: math:: Quaternion<T>:: operator==(const Quaternion<T>& other) const
| Parameters | |
|---|---|
| other | quaternion to compare with |
| Returns | true if the two quaternions are equal, false otherwise |
Compare two quaternions
template<typename T>
bool bpf:: math:: Quaternion<T>:: operator!=(const Quaternion<T>& other) const
| Parameters | |
|---|---|
| other | quaternion to compare with |
| Returns | true if the two quaternions are not equal, false otherwise |
Compare two quaternions
template<typename T>
Quaternion<T> bpf:: math:: Quaternion<T>:: operator*(const Quaternion<T>& other) const
| Parameters | |
|---|---|
| other | operand |
| Returns | new quaternion |
Performs quaternion-quaternion multiplication
template<typename T>
Quaternion<T> bpf:: math:: Quaternion<T>:: operator*(const T& other) const
| Parameters | |
|---|---|
| other | operand |
| Returns | new quaternion |
Performs quaternion-scalar multiplication
template<typename T>
Quaternion<T> bpf:: math:: Quaternion<T>:: operator+(const Quaternion<T>& other) const
| Parameters | |
|---|---|
| other | operand |
| Returns | new quaternion |
Performs quaternion-quaternion addition
template<typename T>
Quaternion<T> bpf:: math:: Quaternion<T>:: operator-(const Quaternion<T>& other) const
| Parameters | |
|---|---|
| other | operand |
| Returns | new quaternion |
Performs quaternion-quaternion subtraction
template<typename T>
T bpf:: math:: Quaternion<T>:: Dot(const Quaternion<T>& other) const
| Parameters | |
|---|---|
| other | operand |
| Returns | number |
Computes a dot product between two quaternions
template<typename T>
T bpf:: math:: Quaternion<T>:: Angle(const Quaternion<T>& other) const
| Parameters | |
|---|---|
| other | operand |
| Returns | number |
Returns the angle between two quaternions. WARNING : Angle is expressed in radians
template<typename T>
Vector<T, 3> bpf:: math:: Quaternion<T>:: ToEulerAngles() const
| Returns | 3D vector, X = Pitch, Y = Yaw, Z = Roll |
|---|
Returns the euler angles representation of that quaternion. WARNING : Angles are expressed in radians
Variable documentation
template<typename T>
static const Quaternion<T> bpf:: math:: Quaternion<T>:: Zero
Zero quaternion constant
template<typename T>
static const Quaternion<T> bpf:: math:: Quaternion<T>:: Identity
Identity quaternion constant
template<typename T>
T bpf:: math:: Quaternion<T>:: I
Imaginary I component
template<typename T>
T bpf:: math:: Quaternion<T>:: J
Imaginary J component
template<typename T>
T bpf:: math:: Quaternion<T>:: K
Imaginary K component
template<typename T>
T bpf:: math:: Quaternion<T>:: W
Real component