Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
Quaternion.hpp
Go to the documentation of this file.
1/*
2Copyright (C) 2017-2019,2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#ifndef AEONGAMES_QUATERNION_H
18#define AEONGAMES_QUATERNION_H
24
26
27namespace AeonGames
28{
29 class Matrix4x4;
30 class Matrix3x3;
31 class Vector3;
34 {
35 public:
44 DLL Quaternion ( float w, float x, float y, float z );
48 DLL Quaternion ( const float* aData );
52 DLL void Get ( float* aData ) const;
58 DLL Matrix4x4 GetMatrix4x4() const;
62 DLL Matrix3x3 GetMatrix3x3() const;
65
66 DLL Quaternion& operator= ( const float* aLhs );
68 DLL Quaternion& operator*= ( const Quaternion& lhs );
70 DLL float operator[] ( const size_t aIndex ) const;
72 DLL float& operator [] ( const size_t aIndex );
74
81 DLL static const Quaternion GetFromAxisAngle ( float angle, float x, float y, float z );
86 DLL static const Quaternion GetFromEuler ( const Vector3& aEuler );
90 DLL Quaternion& Normalize();
94 DLL Vector3 GetEuler() const;
99 DLL Quaternion& SetEuler ( const Vector3& aEuler );
100 private:
102 float mQuaternion[4] {1.0f, 0.0f, 0.0f, 0.0f};
103 };
104
109 DLL const Quaternion operator* ( const Quaternion& lhs, const Quaternion& rhs );
115 DLL const Vector3 operator* ( const Quaternion& lhs, const Vector3& rhs );
121 DLL bool operator== ( const Quaternion& lhs, const Quaternion& rhs );
122
123
132 DLL const Quaternion LerpQuats ( const Quaternion& q1, const Quaternion& q2, double interpolation );
133
142 DLL const Quaternion NlerpQuats ( const Quaternion& q1, const Quaternion& q2, double interpolation );
143
149 DLL const Quaternion SlerpQuats ( const Quaternion& q1, const Quaternion& q2, float interpolation );
150}
151#endif
Platform-specific macros, includes, and DLL export/import definitions.
3 by 3 matrix in colum mayor order.
Definition Matrix3x3.hpp:33
4 by 4 matrix in colum mayor order.
Definition Matrix4x4.hpp:35
DLL Quaternion & operator=(const float *aLhs)
Assign from a raw float array.
DLL Vector3 GetEuler() const
Get the Euler angle representation of this quaternion.
DLL ~Quaternion()
destructor.
static DLL const Quaternion GetFromEuler(const Vector3 &aEuler)
Create a quaternion from Euler angles.
DLL Quaternion & operator*=(const Quaternion &lhs)
Multiply this quaternion by another quaternion.
static DLL const Quaternion GetFromAxisAngle(float angle, float x, float y, float z)
Create a quaternion from an axis-angle representation.
DLL Matrix4x4 GetMatrix4x4() const
Convert the quaternion to a 4x4 rotation matrix.
DLL Matrix3x3 GetMatrix3x3() const
Convert the quaternion to a 3x3 rotation matrix.
DLL Quaternion & SetEuler(const Vector3 &aEuler)
Set the quaternion from Euler angles.
DLL Quaternion & Normalize()
Normalize this quaternion in place.
DLL void Get(float *aData) const
Copy the quaternion components to a float array.
DLL Quaternion()
Default constructor.
DLL float operator[](const size_t aIndex) const
Access a quaternion component by index (const).
3D vector class.
Definition Vector3.hpp:32
<- This is here just for the literals
Definition AABB.hpp:31
DLL const Matrix3x3 operator*(const Matrix3x3 &lhs, const Matrix3x3 &rhs)
Multiplies two 3x3 matrices. Multiplies two 3x3 matrices.
DLL const Quaternion NlerpQuats(const Quaternion &q1, const Quaternion &q2, double interpolation)
Linearly interpolate between two quaternions return the normalized result.
DLL const Quaternion LerpQuats(const Quaternion &q1, const Quaternion &q2, double interpolation)
Linearly interpolate between two quaternions.
DLL const Quaternion SlerpQuats(const Quaternion &q1, const Quaternion &q2, float interpolation)
Spherical Linear interpolation between two quaternions.
DLL const bool operator==(const Matrix3x3 &lhs, const Matrix3x3 &rhs)
Compare two 3x3 matrices for equality.