NW4F G3d
Loading...
Searching...
No Matches
g3d_Matrix34.h
Go to the documentation of this file.
1#ifndef NW_G3D_MATH_MATRIX34_H_
2#define NW_G3D_MATH_MATRIX34_H_
3
4#include <nw/g3d/g3d_config.h>
5#include <nw/g3d/math/g3d_Vector4.h>
6
7namespace nw { namespace g3d { namespace math {
8
9class Vec3;
10class Quat;
11
12struct Mtx34_t
13{
14 enum { DIM_MAJOR = 3, DIM_MINOR = 4, DIM = DIM_MAJOR * DIM_MINOR, DIM_PS = DIM / 2 };
15
16 union
17 {
18 struct
19 {
20 float m00, m01, m02, m03;
21 float m10, m11, m12, m13;
22 float m20, m21, m22, m23;
23 };
24 float a[DIM];
27#if defined( __ghs__ )
28 f32x2 ps[DIM_PS];
29#endif // defined( __ghs__ )
30 };
31};
32
33class Mtx34 : public Mtx34_t
34{
35public:
36 static Mtx34 Make(
37 float m00, float m01, float m02, float m03,
38 float m10, float m11, float m12, float m13,
39 float m20, float m21, float m22, float m23);
40 static Mtx34* Cast(float* a);
41 static const Mtx34* Cast(const float* a);
42
43 Mtx34& Set(
44 float m00, float m01, float m02, float m03,
45 float m10, float m11, float m12, float m13,
46 float m20, float m21, float m22, float m23);
47 Mtx34& Set(const float* a);
48 Mtx34& Set(const Mtx34& m);
49 Mtx34& Set(const Vec3& x, const Vec3& y, const Vec3& z, const Vec3& w);
50 Mtx34& Zero();
51 Mtx34& Identity();
52 Mtx34& Neg(const Mtx34& m);
53
54 Mtx34& SetS(const Vec3& s);
55 Mtx34& SetR(const Vec3& r);
56 Mtx34& SetR(const Quat& r);
57 Mtx34& SetT(const Vec3& t);
58 Mtx34& SetSR(const Vec3& s, const Vec3& r);
59 Mtx34& SetSR(const Vec3& s, const Quat& r);
60
61 Mtx34& Add(const Mtx34& lhs, const Mtx34& rhs);
62 Mtx34& Sub(const Mtx34& lhs, const Mtx34& rhs);
63 Mtx34& Mul(const Mtx34& lhs, const Mtx34& rhs);
64 Mtx34& Mul(const Mtx34& lhs, float rhs);
65 Mtx34& Div(const Mtx34& lhs, float rhs);
66
67 static float Det(const Mtx34& m);
68 Mtx34& Transpose(const Mtx34& m);
69 Mtx34& Adjugate(const Mtx34& m);
70 Mtx34& Cofactor(const Mtx34& m);
71 Mtx34& Inverse(float* pDet, const Mtx34& m);
72 Mtx34& InvTranspose(float* pDet, const Mtx34& m);
73
74 Mtx34& ScaleBases(const Mtx34& m, const Vec3& s);
75 static float ExtractBaseScale(const Mtx34& m, int axis);
76 static float ExtractBaseScaleSq(const Mtx34& m, int axis);
77 Mtx34& LookAt(const Vec3& camPos, const Vec3& camUp, const Vec3& target);
78
79 Mtx34& TexProjFrustum(float l, float r, float b, float t, float n);
80
81 Mtx34& TexProjPerspective(float fovy, float aspect);
82
83 Mtx34& TexProjOrtho(float l, float r, float b, float t);
84};
85
86} } } // namespace nw::g3d::math
87
88#include "inl/g3d_Matrix34-inl.h"
89
90#endif // NW_G3D_MATH_MATRIX34_H_
Definition g3d_Matrix34.h:34
Mtx34 & Mul(const Mtx34 &lhs, float rhs)
Definition g3d_Matrix34-inl.h:357
static float Det(const Mtx34 &m)
Definition g3d_Matrix34-inl.h:386
static float ExtractBaseScale(const Mtx34 &m, int axis)
Definition g3d_Matrix34-inl.h:503
Mtx34 & ScaleBases(const Mtx34 &m, const Vec3 &s)
Definition g3d_Matrix34-inl.h:484
Mtx34 & Inverse(float *pDet, const Mtx34 &m)
Definition g3d_Matrix34-inl.h:460
Mtx34 & Adjugate(const Mtx34 &m)
Definition g3d_Matrix34-inl.h:408
Mtx34 & InvTranspose(float *pDet, const Mtx34 &m)
Definition g3d_Matrix34-inl.h:471
Mtx34 & Set(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23)
Definition g3d_Matrix34-inl.h:33
Mtx34 & Div(const Mtx34 &lhs, float rhs)
Definition g3d_Matrix34-inl.h:376
static Mtx34 * Cast(float *a)
Definition g3d_Matrix34-inl.h:21
Mtx34 & SetS(const Vec3 &s)
Definition g3d_Matrix34-inl.h:111
Mtx34 & Transpose(const Mtx34 &m)
Definition g3d_Matrix34-inl.h:396
Mtx34 & Set(const float *a)
Definition g3d_Matrix34-inl.h:45
Mtx34 & Add(const Mtx34 &lhs, const Mtx34 &rhs)
Definition g3d_Matrix34-inl.h:246
Mtx34 & SetR(const Quat &r)
Definition g3d_Matrix34-inl.h:150
Mtx34 & Mul(const Mtx34 &lhs, const Mtx34 &rhs)
Definition g3d_Matrix34-inl.h:284
Mtx34 & TexProjPerspective(float fovy, float aspect)
Definition g3d_Matrix34-inl.h:580
Mtx34 & SetSR(const Vec3 &s, const Quat &r)
Definition g3d_Matrix34-inl.h:216
Mtx34 & Neg(const Mtx34 &m)
Definition g3d_Matrix34-inl.h:92
Mtx34 & TexProjFrustum(float l, float r, float b, float t, float n)
Definition g3d_Matrix34-inl.h:549
Mtx34 & SetR(const Vec3 &r)
Definition g3d_Matrix34-inl.h:122
Mtx34 & Identity()
Definition g3d_Matrix34-inl.h:83
Mtx34 & Set(const Mtx34 &m)
Definition g3d_Matrix34-inl.h:56
Mtx34 & SetT(const Vec3 &t)
Definition g3d_Matrix34-inl.h:178
Mtx34 & Zero()
Definition g3d_Matrix34-inl.h:73
Mtx34 & LookAt(const Vec3 &camPos, const Vec3 &camUp, const Vec3 &target)
Definition g3d_Matrix34-inl.h:519
Mtx34 & Set(const Vec3 &x, const Vec3 &y, const Vec3 &z, const Vec3 &w)
Definition g3d_Matrix34-inl.h:66
static const Mtx34 * Cast(const float *a)
Definition g3d_Matrix34-inl.h:27
static Mtx34 Make(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23)
Definition g3d_Matrix34-inl.h:9
Mtx34 & Cofactor(const Mtx34 &m)
Definition g3d_Matrix34-inl.h:436
Mtx34 & Sub(const Mtx34 &lhs, const Mtx34 &rhs)
Definition g3d_Matrix34-inl.h:265
static float ExtractBaseScaleSq(const Mtx34 &m, int axis)
Definition g3d_Matrix34-inl.h:509
Mtx34 & TexProjOrtho(float l, float r, float b, float t)
Definition g3d_Matrix34-inl.h:614
Mtx34 & SetSR(const Vec3 &s, const Vec3 &r)
Definition g3d_Matrix34-inl.h:188
Definition g3d_Quaternion.h:28
Definition g3d_Vector3.h:30
Definition g3d_Vector4.h:26
Definition g3d_MathCommon.h:6
Definition g3d_GfxManage.cpp:10
Definition g3d_Matrix34.h:13
Vec4 v[DIM_MAJOR]
Definition g3d_Matrix34.h:26
float m23
Definition g3d_Matrix34.h:22
float m[DIM_MAJOR][DIM_MINOR]
Definition g3d_Matrix34.h:25
float m13
Definition g3d_Matrix34.h:21
float m21
Definition g3d_Matrix34.h:22
float m10
Definition g3d_Matrix34.h:21
float m20
Definition g3d_Matrix34.h:22
float m00
Definition g3d_Matrix34.h:20
float m01
Definition g3d_Matrix34.h:20
@ DIM_MINOR
Definition g3d_Matrix34.h:14
@ DIM_MAJOR
Definition g3d_Matrix34.h:14
@ DIM
Definition g3d_Matrix34.h:14
@ DIM_PS
Definition g3d_Matrix34.h:14
float m12
Definition g3d_Matrix34.h:21
float m02
Definition g3d_Matrix34.h:20
float m03
Definition g3d_Matrix34.h:20
float m11
Definition g3d_Matrix34.h:21
float m22
Definition g3d_Matrix34.h:22
float a[DIM]
Definition g3d_Matrix34.h:24