Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TMatrix4.h
Go to the documentation of this file.
1#pragma once
2
3#include "Math/math_fwd.h"
4
5#include <Common/primitive_type.h>
6
7#include <string>
8#include <array>
9
10namespace ph::math
11{
12
15template<typename T>
16class TMatrix4 final
17{
18public:
19 static TMatrix4 makeIdentity();
20
21public:
22 using Elements = std::array<std::array<T, 4>, 4>;
23
25
26public:
27 inline TMatrix4() = default;
28 explicit TMatrix4(T value);
29 explicit TMatrix4(const Elements& elements);
30 inline TMatrix4(const TMatrix4& other) = default;
31
32 template<typename U>
33 explicit TMatrix4(const TMatrix4<U>& other);
34
36 TMatrix4& initTranslation(T x, T y, T z);
39 TMatrix4& initRotation(const TVector3<T>& orthBasisX, const TVector3<T>& orthBasisY, const TVector3<T>& orthBasisZ);
40 TMatrix4& initScale(T x, T y, T z);
41 TMatrix4& initScale(const TVector3<T>& scale);
43 T aspectRatio,
44 T zNear,
45 T zFar);
46
47 TMatrix4 mul(const TMatrix4& rhs) const;
48 void mul(const TMatrix4& rhs, TMatrix4* out_result) const;
49 void mul(const TVector3<T>& rhsXYZ, T rhsW, TVector3<T>* out_result) const;
50 TMatrix4& mulLocal(T rhs);
51
52 TMatrix4& inverse(TMatrix4* out_result) const;
53 TMatrix4 transpose() const;
54
55 T determinant() const;
56
57 bool isEqual(const TMatrix4& other) const;
58 std::string toString() const;
59};
60
61}// end namespace ph::math
62
63#include "Math/TMatrix4.ipp"
Represents a 4x4 matrix.
Definition TMatrix4.h:17
static TMatrix4 makeIdentity()
Definition TMatrix4.ipp:15
TMatrix4(const TMatrix4 &other)=default
TMatrix4 mul(const TMatrix4 &rhs) const
Definition TMatrix4.ipp:150
TMatrix4 & initRotation(const TQuaternion< T > &rot)
Definition TMatrix4.ipp:79
TMatrix4 & mulLocal(T rhs)
Definition TMatrix4.ipp:196
std::string toString() const
Definition TMatrix4.ipp:321
std::array< std::array< T, 4 >, 4 > Elements
Definition TMatrix4.h:22
TMatrix4 & initScale(T x, T y, T z)
Definition TMatrix4.ipp:116
bool isEqual(const TMatrix4 &other) const
Definition TMatrix4.ipp:302
T determinant() const
Definition TMatrix4.ipp:281
TMatrix4 & initTranslation(T x, T y, T z)
Definition TMatrix4.ipp:62
Elements m
Definition TMatrix4.h:24
TMatrix4 & initPerspectiveProjection(T fov, T aspectRatio, T zNear, T zFar)
Definition TMatrix4.ipp:133
TMatrix4 & initIdentity()
Definition TMatrix4.ipp:51
TMatrix4 & inverse(TMatrix4 *out_result) const
Definition TMatrix4.ipp:222
TMatrix4 transpose() const
Definition TMatrix4.ipp:266
Represents a quaternion.
Definition TQuaternion.h:17
Represents a 3-D vector.
Definition TVector3.h:17
Math functions and utilities.
Definition TransformInfo.h:10