Topaz 5.0
Topaz Game Engine
Loading...
Searching...
No Matches
quaternion.hpp
1#ifndef TOPAZ_CORE_QUATERNION_HPP
2#define TOPAZ_CORE_QUATERNION_HPP
3#include "tz/core/vector.hpp"
4#include "tz/core/matrix.hpp"
5
6namespace tz
7{
12 struct quat : public tz::v4f
13 {
15 static quat iden()
16 {
17 return {tz::v4f{0.0f, 0.0f, 0.0f, 1.0f}};
18 }
19 quat() = default;
23 static quat from_axis_angle(tz::v3f axis, float angle);
25 static quat from_euler_angles(tz::v3f euler_angles);
27 tz::m4f matrix() const;
29 quat inverse() const;
31 quat combine(const quat& rhs) const;
35 quat normalise() const;
37 quat slerp(const quat& rhs, float factor) const;
38
39 quat& operator*=(const quat& rhs);
40 quat operator*(const quat& rhs) const{auto cpy = *this; return cpy *= rhs;}
41 };
42}
43
44#endif // TOPAZ_CORE_QUATERNION_HPP
Represents the generic matrix.
Definition matrix.hpp:16
Quaternion. Represents a rotation in 3D space.
Definition quaternion.hpp:13
quat slerp(const quat &rhs, float factor) const
Retrieve a quaternion that represents a spherical interpolation between this quaternion and another,...
tz::v3f rotate(tz::v3f pos) const
Rotate a 3D position by this quaternion.
quat(tz::v4f vec)
Create a quaternion directly from xyzw components.
tz::m4f matrix() const
Create a rotation matrix that transforms identically to the quaternion.
static quat iden()
Retrieve the identity quaternion, that is - represents no transformation.
Definition quaternion.hpp:15
static quat from_axis_angle(tz::v3f axis, float angle)
Create a quaternion that represents a rotation about a certain axis.
static quat from_euler_angles(tz::v3f euler_angles)
Create a quaternion that represents a rotation equivalent to the provided euler angles.
quat normalise() const
Retrieve a normalised copy of the quaternion.
quat inverse() const
Create a quaternion that causes the inverse transformation. Such that the product of this and the res...
quat combine(const quat &rhs) const
Combine one quaternion with another, producing a result equal to applying both rotations.