3#include <Foundation/Math/Vec3.h>
17template <
typename Type>
22 PL_DECLARE_POD_TYPE();
24 using ComponentType = Type;
40#if PL_ENABLED(PL_MATH_CHECK_FOR_NAN)
41 void AssertNotNaN()
const
43 PL_ASSERT_ALWAYS(!
IsNaN(),
"This object contains NaN values. This can happen when you forgot to initialize it before using it. Please check that "
44 "all code-paths properly initialize this object.");
93 const Type*
GetData()
const {
return &x; }
111 bool IsValid(Type fEpsilon = plMath::DefaultEpsilon<Type>())
const;
150template <
typename Type>
154template <
typename Type>
157template <
typename Type>
160template <
typename Type>
163#include <Foundation/Math/Implementation/Quat_inl.h>
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
A 3x3 component matrix class.
Definition Mat3.h:9
A 4x4 component matrix class.
Definition Mat4.h:11
Quaternions can be used to represent rotations in 3D space.
Definition Quat.h:19
const Type * GetData() const
Returns the data as an array.
Definition Quat.h:93
void ReconstructFromMat4(const plMat4Template< Type > &m)
Reconstructs a rotation quaternion from a matrix that may contain scaling and mirroring.
Definition Quat_inl.h:342
void SetIdentity()
Sets the Quaternion to the identity.
Definition Quat_inl.h:41
plVec3Template< Type > GetVectorPart() const
Returns the x,y,z components as a vector.
Definition Quat.h:102
static plQuatTemplate< Type > MakeSlerp(const plQuatTemplate &qFrom, const plQuatTemplate &qTo, Type t)
Returns a quaternion that is the spherical linear interpolation of the other two.
Definition Quat_inl.h:403
static plQuatTemplate< Type > MakeFromMat3(const plMat3Template< Type > &m)
Creates a quaternion from the given matrix.
Definition Quat_inl.h:275
const plQuatTemplate< Type > GetInverse() const
Returns a quaternion that represents the negative / inverted rotation. E.g. the one that would rotate...
Definition Quat_inl.h:106
const plQuatTemplate< Type > GetNegated() const
Returns the Quaternion with all 4 components negated. This is not the same as the inverted rotation!
Definition Quat_inl.h:114
Type * GetData()
Returns the data as an array.
Definition Quat.h:96
void Normalize()
Normalizes the quaternion to unit length. ALL rotation-quaternions should be normalized at all times ...
Definition Quat_inl.h:61
bool IsEqualRotation(const plQuatTemplate &qOther, Type fEpsilon) const
Determines whether this and qOther represent the same rotation. This is a rather slow operation.
Definition Quat_inl.h:181
static plQuatTemplate< Type > MakeFromElements(Type x, Type y, Type z, Type w)
Sets the individual elements of the quaternion directly. Note that x,y,z do NOT represent a rotation ...
Definition Quat_inl.h:35
void GetRotationAxisAndAngle(plVec3Template< Type > &out_vAxis, plAngle &out_angle, Type fEpsilon=plMath::DefaultEpsilon< Type >()) const
Returns the rotation-axis and angle, that this quaternion rotates around.
Definition Quat_inl.h:76
static plQuatTemplate< Type > MakeFromEulerAngles(const plAngle &x, const plAngle &y, const plAngle &z)
Sets the quaternion from Euler angles.
Definition Quat_inl.h:520
plVec3Template< Type > Rotate(const plVec3Template< Type > &v) const
Returns v rotated by the quaternion. Same as operator*.
Definition Quat_inl.h:131
bool IsNaN() const
Checks whether any component is NaN.
Definition Quat_inl.h:175
const plMat4Template< Type > GetAsMat4() const
Returns the Quaternion as a matrix.
Definition Quat_inl.h:236
static const plQuatTemplate< Type > MakeIdentity()
Static function that returns a quaternion that represents the identity rotation (none).
Definition Quat_inl.h:29
void ReconstructFromMat3(const plMat3Template< Type > &m)
Reconstructs a rotation quaternion from a matrix that may contain scaling and mirroring.
Definition Quat_inl.h:327
static plQuatTemplate< Type > MakeShortestRotation(const plVec3Template< Type > &vDirFrom, const plVec3Template< Type > &vDirTo)
Creates a quaternion, that rotates through the shortest arc from "vDirFrom" to "vDirTo".
Definition Quat_inl.h:363
const plMat3Template< Type > GetAsMat3() const
Returns the Quaternion as a matrix.
Definition Quat_inl.h:204
static plQuatTemplate< Type > MakeFromAxisAndAngle(const plVec3Template< Type > &vRotationAxis, plAngle angle)
Creates a quaternion from a rotation-axis and an angle.
Definition Quat_inl.h:50
Type Dot(const plQuatTemplate &rhs) const
Returns the dot-product of the two quaternions (commutative, order does not matter).
Definition Quat_inl.h:122
void GetAsEulerAngles(plAngle &out_x, plAngle &out_y, plAngle &out_z) const
Converts the quaternion to Euler angles.
Definition Quat_inl.h:477
bool IsValid(Type fEpsilon=plMath::DefaultEpsilon< Type >()) const
Checks whether all components are neither NaN nor infinite and that the quaternion is normalized.
Definition Quat_inl.h:162
void Invert()
Inverts the rotation, so instead of rotating N degrees around an axis, the quaternion will rotate -N ...
Definition Quat_inl.h:98
A 3-component vector class.
Definition Vec3.h:9