7 #ifndef NAZARA_QUATERNION_HPP 8 #define NAZARA_QUATERNION_HPP 10 #include <Nazara/Core/String.hpp> 14 struct SerializationContext;
16 template<
typename T>
class EulerAngles;
17 template<
typename T>
class Vector3;
19 template<
typename T>
class Quaternion
22 Quaternion() =
default;
23 Quaternion(T W, T X, T Y, T Z);
24 Quaternion(
const EulerAngles<T>& angles);
25 Quaternion(T angle,
const Vector3<T>& axis);
26 Quaternion(
const T quat[4]);
28 template<
typename U>
explicit Quaternion(
const Quaternion<U>& quat);
29 Quaternion(
const Quaternion& quat) =
default;
30 ~Quaternion() =
default;
39 Quaternion
GetNormal(T* length =
nullptr)
const;
49 Quaternion&
Normalize(T* length =
nullptr);
51 Quaternion&
Set(T W, T X, T Y, T Z);
52 Quaternion&
Set(
const EulerAngles<T>& angles);
53 Quaternion&
Set(T angle,
const Vector3<T>& normalizedAxis);
54 Quaternion&
Set(
const T quat[4]);
56 Quaternion&
Set(
const Quaternion& quat);
57 template<
typename U> Quaternion&
Set(
const Quaternion<U>& quat);
65 Quaternion& operator=(
const Quaternion& quat) =
default;
67 Quaternion
operator+(
const Quaternion& quat)
const;
68 Quaternion
operator*(
const Quaternion& quat)
const;
69 Vector3<T>
operator*(
const Vector3<T>& vec)
const;
71 Quaternion
operator/(
const Quaternion& quat)
const;
73 Quaternion&
operator+=(
const Quaternion& quat);
74 Quaternion&
operator*=(
const Quaternion& quat);
76 Quaternion&
operator/=(
const Quaternion& quat);
82 static Quaternion
Lerp(
const Quaternion& from,
const Quaternion& to, T interpolation);
83 static Quaternion
Normalize(
const Quaternion& quat, T* length =
nullptr);
84 static Quaternion
RotationBetween(
const Vector3<T>& from,
const Vector3<T>& to);
85 static Quaternion
Slerp(
const Quaternion& from,
const Quaternion& to, T interpolation);
86 static Quaternion
Zero();
91 typedef Quaternion<double> Quaterniond;
92 typedef Quaternion<float> Quaternionf;
94 template<
typename T>
bool Serialize(SerializationContext& context,
const Quaternion<T>& quat);
95 template<
typename T>
bool Unserialize(SerializationContext& context, Quaternion<T>* quat);
98 template<
typename T> std::ostream& operator<<(std::ostream& out, const Nz::Quaternion<T>& quat);
100 #include <Nazara/Math/Quaternion.inl> 102 #endif // NAZARA_QUATERNION_HPP TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Quaternion GetInverse() const
Gets the inverse of this quaternion.
Definition: Quaternion.inl:180
T SquaredMagnitude() const
Calculates the squared magnitude (length) of the quaternion.
Definition: Quaternion.inl:466
T DotProduct(const Quaternion &vec) const
Calculates the dot (scalar) product with two quaternions.
Definition: Quaternion.inl:147
bool Unserialize(SerializationContext &context, bool *value)
Unserializes a boolean.
Definition: Algorithm.inl:279
Quaternion & ComputeW()
Computes the w component of the quaternion to make it unit.
Definition: Quaternion.inl:108
Quaternion operator/(const Quaternion &quat) const
Divides the quaternion with other quaternion.
Definition: Quaternion.inl:589
Quaternion & Inverse()
Inverts this quaternion.
Definition: Quaternion.inl:218
EulerAngles< T > ToEulerAngles() const
Converts this quaternion to Euler angles representation.
Definition: Quaternion.inl:479
Quaternion & MakeZero()
Makes the quaternion (0, 0, 0, 0)
Definition: Quaternion.inl:293
Quaternion & Normalize(T *length=nullptr)
Normalizes the current quaternion.
Definition: Quaternion.inl:323
Quaternion operator*(const Quaternion &quat) const
Multiplies of the quaternion with other quaternion.
Definition: Quaternion.inl:535
bool operator==(const Quaternion &quat) const
Compares the quaternion to other one.
Definition: Quaternion.inl:654
Quaternion & Conjugate()
Returns the rotational conjugate of this quaternion.
Definition: Quaternion.inl:130
Quaternion & MakeIdentity()
Makes the quaternion (1, 0, 0, 0)
Definition: Quaternion.inl:242
Quaternion & operator*=(const Quaternion &quat)
Multiplies of the quaternion with other quaternion.
Definition: Quaternion.inl:615
Quaternion GetConjugate() const
Gets the rotational conjugate of this quaternion.
Definition: Quaternion.inl:162
Quaternion & operator+=(const Quaternion &quat)
Adds the components of the quaternion with other quaternion.
Definition: Quaternion.inl:602
static Quaternion Lerp(const Quaternion &from, const Quaternion &to, T interpolation)
Interpolates the quaternion to other one with a factor of interpolation.
Definition: Quaternion.inl:706
Quaternion & MakeRotationBetween(const Vector3< T > &from, const Vector3< T > &to)
Makes this quaternion to the rotation required to rotate direction Vector3 from to direction Vector3 ...
Definition: Quaternion.inl:258
bool operator!=(const Quaternion &quat) const
Compares the quaternion to other one.
Definition: Quaternion.inl:670
Quaternion & Set(T W, T X, T Y, T Z)
Sets the components of the quaternion.
Definition: Quaternion.inl:352
bool Serialize(SerializationContext &context, bool value)
Serializes a boolean.
Definition: Algorithm.inl:214
static Quaternion Slerp(const Quaternion &from, const Quaternion &to, T interpolation)
Interpolates spherically the quaternion to other one with a factor of interpolation.
Definition: Quaternion.inl:775
static Quaternion Zero()
Shorthand for the quaternion (0, 0, 0, 0)
Definition: Quaternion.inl:828
static Quaternion RotationBetween(const Vector3< T > &from, const Vector3< T > &to)
Gets the rotation required to rotate direction Vector3 from to direction Vector3 to.
Definition: Quaternion.inl:752
Quaternion GetNormal(T *length=nullptr) const
Gets the normalization of this quaternion.
Definition: Quaternion.inl:200
Quaternion & operator/=(const Quaternion &quat)
Divides the quaternion with other quaternion.
Definition: Quaternion.inl:641
Quaternion operator+(const Quaternion &quat) const
Adds the components of the quaternion with other quaternion.
Definition: Quaternion.inl:516
T Magnitude() const
Calculates the magnitude (length) of the quaternion.
Definition: Quaternion.inl:306
String ToString() const
Gives a string representation.
Definition: Quaternion.inl:501
static Quaternion Identity()
Shorthand for the quaternion (1, 0, 0, 0)
Definition: Quaternion.inl:683