Faro Engine 0.0.0.b519570 (main)
Loading...
Searching...
No Matches
Matrix44.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Vector2.hpp"
4#include "Vector3.hpp"
5#include "Vector4.hpp"
6
7namespace Faro
8{
9 struct Matrix44
10 {
11 union
12 {
13 float m[4][4];
14 float f[16];
15 };
16
17 Matrix44(float m00, float m01, float m02, float m03,
18 float m10, float m11, float m12, float m13,
19 float m20, float m21, float m22, float m23,
20 float m30, float m31, float m32, float m33);
21
22 Matrix44();
23
25
27
29
30 Matrix44 operator+(const Matrix44& mat) const;
31
32 Matrix44 operator-(const Matrix44& mat) const;
33
34 Matrix44 operator*(const Matrix44& mat) const;
35
36 /// Translation bit of the matrix
37 Float3D GetTranslation() const;
38
39 /// Set the transltion of the matrix
40 void SetTranslation(const Float3D& vec);
41
42 /// Get the x orientation axis
43 Float3D GetXAxis() const;
44
45 /// Get the y orientation axis
46 Float3D GetYAxis() const;
47
48 /// Get the z orientation axis
49 Float3D GetZAxis() const;
50
51 /// Get the determinant of this matrix
52 float Determinant() const;
53
54 /// Inverts this matrix
55 bool Invert();
56
57 /// Transposes this matrix
58 void Transpose();
59
60 /// Returns tthis matrix transposed
62
63 Matrix44 Get();
64
65 /// Sets the orientation of the matrix to the orthogonal basis vector
66 /// It perfoms no checks on the orthogonality!
67 ///
68 /// @param x X orthogonal basis vector
69 /// @param y Y orthogonal basis vector
70 /// @param z Z orthogonal basis vector
71 void SetOrientation(const Float3D& x,
72 const Float3D& y,
73 const Float3D& z);
74
75 /// Set orientation using Euler angles. Broken at current!
76 void SetEulerAxis(float yaw, float pitch, float roll);
77
78 /// Creates an identity matrix
79 ///
80 /// @return Identity matrix
81 static Matrix44 CreateIdentity();
82
83 /// Creates a transation matrix
84 ///
85 /// @return Translation matrix
86 static Matrix44 CreateTranslation(Float3D translation);
87
88 static Matrix44 CreateScale(Float3D scale);
89
90 /// Creates a rotation matrix around an arbitrary axis
91 static Matrix44 CreateRotate(float angle, const Float3D& axis);
92
93 /// Angle in radians
94 static Matrix44 CreateRotateX(float angle);
95
96 /// Angle in radians
97 static Matrix44 CreateRotateY(float angle);
98
99 /// Angle in radians
100 static Matrix44 CreateRotateZ(float angle);
101
102 /// Creates an orthographic projection matrix
103 static Matrix44 CreateOrtho(float left, float right, float bottom, float top, float nearZ, float farZ);
104
105 /// Creates a frustum projection matrix
106 static Matrix44 CreateFrustum(float left, float right, float bottom, float top, float nearZ, float farZ);
107
108 /// Creates a perspective projection matrix from camera settings
109 static Matrix44 CreatePerspective(float fovy, float aspect, float nearZ, float farZ);
110
111 /// Creates a look at matrix, usualy a view matrix
112 static Matrix44 CreateLookAt(const Float3D& eye, const Float3D& center, const Float3D& up);
113
114 /// Transfrom just the direction
115 Float3D TransformDirectionVector(const Float3D& direction);
116 };
117}
Definition Array.hpp:8
Definition Matrix44.hpp:10
Float3D GetZAxis() const
Get the z orientation axis.
Definition Matrix44.cpp:146
Matrix44 Get()
Definition Matrix44.cpp:221
static Matrix44 CreateRotateX(float angle)
Angle in radians.
Definition Matrix44.cpp:304
bool Invert()
Inverts this matrix.
Definition Matrix44.cpp:165
static Matrix44 CreateScale(Float3D scale)
Definition Matrix44.cpp:279
float f[16]
Definition Matrix44.hpp:14
Float3D GetXAxis() const
Get the x orientation axis.
Definition Matrix44.cpp:132
Matrix44 operator-(const Matrix44 &mat) const
Definition Matrix44.cpp:87
static Matrix44 CreatePerspective(float fovy, float aspect, float nearZ, float farZ)
Creates a perspective projection matrix from camera settings.
Definition Matrix44.cpp:355
static Matrix44 CreateRotateZ(float angle)
Angle in radians.
Definition Matrix44.cpp:320
void SetOrientation(const Float3D &x, const Float3D &y, const Float3D &z)
Definition Matrix44.cpp:239
static Matrix44 CreateOrtho(float left, float right, float bottom, float top, float nearZ, float farZ)
Creates an orthographic projection matrix.
Definition Matrix44.cpp:329
void SetEulerAxis(float yaw, float pitch, float roll)
Set orientation using Euler angles. Broken at current!
Definition Matrix44.cpp:252
void Transpose()
Transposes this matrix.
Definition Matrix44.cpp:197
static Matrix44 CreateFrustum(float left, float right, float bottom, float top, float nearZ, float farZ)
Creates a frustum projection matrix.
Definition Matrix44.cpp:340
Float2D operator*(Float2D vec)
Definition Matrix44.cpp:43
static Matrix44 CreateTranslation(Float3D translation)
Definition Matrix44.cpp:271
static Matrix44 CreateRotateY(float angle)
Angle in radians.
Definition Matrix44.cpp:312
static Matrix44 CreateLookAt(const Float3D &eye, const Float3D &center, const Float3D &up)
Creates a look at matrix, usualy a view matrix
Definition Matrix44.cpp:368
Float3D GetYAxis() const
Get the y orientation axis.
Definition Matrix44.cpp:139
float m[4][4]
Definition Matrix44.hpp:13
Matrix44 Transposed()
Returns tthis matrix transposed.
Definition Matrix44.cpp:208
Float3D TransformDirectionVector(const Float3D &direction)
Transfrom just the direction.
Definition Matrix44.cpp:395
Matrix44()
Definition Matrix44.cpp:24
static Matrix44 CreateIdentity()
Definition Matrix44.cpp:266
Matrix44 operator+(const Matrix44 &mat) const
Definition Matrix44.cpp:67
Float3D GetTranslation() const
Translation bit of the matrix.
Definition Matrix44.cpp:119
static Matrix44 CreateRotate(float angle, const Float3D &axis)
Creates a rotation matrix around an arbitrary axis.
Definition Matrix44.cpp:287
float Determinant() const
Get the determinant of this matrix.
Definition Matrix44.cpp:158
void SetTranslation(const Float3D &vec)
Set the transltion of the matrix.
Definition Matrix44.cpp:126
Definition Vector2.hpp:9
Definition Vector3.hpp:9
Definition Vector4.hpp:10