Quaternion.h
Go to the documentation of this file.
#pragma once
#include "Vector3.h"
#include "Vector4.h"
#include "Matrix4x4.h"
namespace Eule
{
class Quaternion
{
public:
Quaternion();
explicit Quaternion(const Vector4d values);
Quaternion(const Quaternion& q);
Quaternion(const Vector3d eulerAngles);
~Quaternion();
Quaternion operator= (const Quaternion& q);
Quaternion operator* (const Quaternion& q) const;
Quaternion operator/ (Quaternion& q) const;
Quaternion& operator*= (const Quaternion& q);
Quaternion& operator/= (const Quaternion& q);
Vector3d operator* (const Vector3d& p) const;
bool operator== (const Quaternion& q) const;
bool operator!= (const Quaternion& q) const;
Quaternion Inverse() const;
Quaternion Conjugate() const;
Quaternion UnitQuaternion() const;
Vector3d RotateVector(const Vector3d& vec) const;
Vector3d ToEulerAngles() const;
Matrix4x4 ToRotationMatrix() const;
Vector4d GetRawValues() const;
Quaternion AngleBetween(const Quaternion& other) const;
void SetRawValues(const Vector4d values);
Quaternion Lerp(const Quaternion& other, double t) const;
friend std::ostream& operator<< (std::ostream& os, const Quaternion& q);
friend std::wostream& operator<< (std::wostream& os, const Quaternion& q);
private:
Quaternion operator* (const double scale) const;
Quaternion& operator*= (const double scale);
Vector4d v;
void InvalidateCache();
// Caches for conversions
mutable bool isCacheUpToDate_euler = false;
mutable Vector3d cache_euler;
mutable bool isCacheUpToDate_matrix = false;
mutable Matrix4x4 cache_matrix;
mutable bool isCacheUpToDate_inverse = false;
mutable Vector4d cache_inverse;
};
}
Eule::Quaternion::operator/
Quaternion operator/(Quaternion &q) const
Divides (applies)
Definition: Quaternion.cpp:126
Eule::Quaternion::ToRotationMatrix
Matrix4x4 ToRotationMatrix() const
Will return a rotation matrix representing this Quaternions rotation.
Definition: Quaternion.cpp:246
Eule::Quaternion::GetRawValues
Vector4d GetRawValues() const
Will return the raw four-dimensional values.
Definition: Quaternion.cpp:290
Eule::Quaternion::AngleBetween
Quaternion AngleBetween(const Quaternion &other) const
Will return the value between two Quaternion's as another Quaternion.
Definition: Quaternion.cpp:295
Eule::Vector3< double >
Eule::Quaternion::Lerp
Quaternion Lerp(const Quaternion &other, double t) const
Will return the lerp result between two quaternions.
Definition: Quaternion.cpp:309
Eule::Quaternion::UnitQuaternion
Quaternion UnitQuaternion() const
Definition: Quaternion.cpp:192
Eule::Quaternion::ToEulerAngles
Vector3d ToEulerAngles() const
Will return euler angles representing this Quaternion's rotation.
Definition: Quaternion.cpp:215
Eule::Quaternion::operator=
Quaternion operator=(const Quaternion &q)
Copies.
Definition: Quaternion.cpp:102
Matrix4x4.h
Eule::Quaternion::~Quaternion
~Quaternion()
Definition: Quaternion.cpp:97
Eule::Quaternion::operator*
Quaternion operator*(const Quaternion &q) const
Multiplies (applies)
Definition: Quaternion.cpp:111
Eule::Matrix4x4
A matrix 4x4 class representing a 3d transformation.
Definition: Matrix4x4.h:36
Eule::Quaternion::operator*=
Quaternion & operator*=(const Quaternion &q)
Also multiplies.
Definition: Quaternion.cpp:131
Eule::Quaternion::SetRawValues
void SetRawValues(const Vector4d values)
Will set the raw four-dimensional values.
Definition: Quaternion.cpp:300
Vector4.h
Eule::Quaternion::RotateVector
Vector3d RotateVector(const Vector3d &vec) const
Will rotate a vector by this quaternion.
Definition: Quaternion.cpp:197
Eule::Quaternion::Quaternion
Quaternion()
Definition: Quaternion.cpp:11
Vector3.h
Eule::Quaternion::Conjugate
Quaternion Conjugate() const
Definition: Quaternion.cpp:187
Eule::Quaternion::Inverse
Quaternion Inverse() const
Definition: Quaternion.cpp:175
Eule::Quaternion::operator==
bool operator==(const Quaternion &q) const
Definition: Quaternion.cpp:165
Eule::Quaternion::operator<<
friend std::ostream & operator<<(std::ostream &os, const Quaternion &q)
Definition: Quaternion.cpp:325
Eule::Quaternion
3D rotation representation
Definition: Quaternion.h:10
Eule::Quaternion::operator!=
bool operator!=(const Quaternion &q) const
Definition: Quaternion.cpp:170
Eule::Quaternion::operator/=
Quaternion & operator/=(const Quaternion &q)
Also divides.
Definition: Quaternion.cpp:152
Eule
Definition: Collider.h:4
Eule::Vector4< double >