Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
Matrix4x4.hpp
Go to the documentation of this file.
1/*
2Copyright (C) 2015-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#ifndef AEONGAMES_MATRIX4X4_H
17#define AEONGAMES_MATRIX4X4_H
23
25#include <initializer_list>
26#include <iosfwd>
27
28namespace AeonGames
29{
30 class Vector3;
31 class Transform;
35 {
36 public:
38 DLL Matrix4x4();
42 DLL Matrix4x4 ( const Transform& aTransform );
46 DLL Matrix4x4 ( const float* const aMatrix );
50 DLL Matrix4x4 ( const std::initializer_list<const float> aList );
56 DLL const float* const GetMatrix4x4() const;
64 DLL Matrix4x4& Invert();
65
74 DLL void Frustum ( float aLeft, float aRight, float aBottom, float aTop, float aNear, float aFar );
83 DLL void Ortho ( float aLeft, float aRight, float aBottom, float aTop, float aNear, float aFar );
90 DLL void Perspective ( float aFieldOfVision, float aAspect, float aNear, float aFar );
91
99 DLL Matrix4x4& Rotate ( float angle, float x, float y, float z );
102
103 DLL Matrix4x4& operator*= ( const Matrix4x4& lhs );
105 DLL const float operator[] ( size_t aIndex ) const;
107
117 DLL static const Matrix4x4 GetRotationMatrix ( float angle, float x, float y, float z );
119 DLL static const Matrix4x4 Identity;
120 protected:
122 float mMatrix[16];
123 };
124
131 DLL const Matrix4x4 operator* ( const Matrix4x4& lhs, const Matrix4x4& rhs );
137 DLL const Vector3 operator* ( const Matrix4x4& lhs, const Vector3& rhs );
143 DLL const bool operator== ( const Matrix4x4& lhs, const Matrix4x4& rhs );
148 DLL const Matrix4x4 Abs ( const Matrix4x4& aMatrix4x4 );
154 DLL std::ostream& operator<< ( std::ostream& os, const Matrix4x4& aMatrix );
155 static_assert ( sizeof ( Matrix4x4 ) == ( sizeof ( float ) * 16 ), "Matrix4x4 is not 16 floats wide." );
156}
157#endif
Platform-specific macros, includes, and DLL export/import definitions.
4 by 4 matrix in colum mayor order.
Definition Matrix4x4.hpp:35
DLL const float *const GetMatrix4x4() const
Get a pointer to the internal matrix data.
Definition Matrix4x4.cpp:53
DLL Matrix4x4()
Default constructor.
Definition Matrix4x4.cpp:27
DLL void Frustum(float aLeft, float aRight, float aBottom, float aTop, float aNear, float aFar)
Set up a perspective projection matrix defined by a frustum.
Definition Matrix4x4.cpp:69
DLL void Perspective(float aFieldOfVision, float aAspect, float aNear, float aFar)
Set up a symmetric perspective projection matrix.
DLL const float operator[](size_t aIndex) const
Access a matrix element by index.
static DLL const Matrix4x4 GetRotationMatrix(float angle, float x, float y, float z)
Constructs the rotation matrix defined by the axis-angle provided.
DLL Matrix4x4 & operator*=(const Matrix4x4 &lhs)
Multiply this matrix by another matrix.
DLL const Matrix4x4 GetInvertedMatrix4x4()
Get the inverted matrix.
Definition Matrix4x4.cpp:64
float mMatrix[16]
Lineal row mayor matrix.
DLL Matrix4x4 & Invert()
Invert this matrix in place.
Definition Matrix4x4.cpp:58
static DLL const Matrix4x4 Identity
The 4x4 identity matrix constant.
DLL void Ortho(float aLeft, float aRight, float aBottom, float aTop, float aNear, float aFar)
Set up an orthographic projection matrix.
Definition Matrix4x4.cpp:97
DLL ~Matrix4x4()
destructor.
DLL Matrix4x4 & Rotate(float angle, float x, float y, float z)
Apply a rotation to this matrix.
Component class for any object that requires space transformations.
Definition Transform.hpp:34
3D vector class.
Definition Vector3.hpp:32
<- This is here just for the literals
Definition AABB.hpp:31
std::ostream & operator<<(std::ostream &os, LogLevel level)
Inserts a color-coded log level tag into an output stream.
Definition LogLevel.hpp:40
DLL const Matrix3x3 operator*(const Matrix3x3 &lhs, const Matrix3x3 &rhs)
Multiplies two 3x3 matrices. Multiplies two 3x3 matrices.
DLL const Matrix3x3 Abs(const Matrix3x3 &aMatrix3x3)
Compute the element-wise absolute value of a matrix.
DLL const bool operator==(const Matrix3x3 &lhs, const Matrix3x3 &rhs)
Compare two 3x3 matrices for equality.