8 enum EZeroCtor { ZeroCtor };
9 enum EIdentityCtor { IdentityCtor };
10 enum ERowsCtor { RowsCtor };
11 enum EColsCtor { ColsCtor };
14 cMat4(
const EZeroCtor);
15 cMat4(
const EIdentityCtor);
20 cMat4(
const float _00,
const float _01,
const float _02,
const float _03,
21 const float _10,
const float _11,
const float _12,
const float _13,
22 const float _20,
const float _21,
const float _22,
const float _23,
23 const float _30,
const float _31,
const float _32,
const float _33);
24 cMat4(
const cMat4& v) { memcpy(
this, &v,
sizeof(v)); }
26 void Copy(
const float *Float16);
27 void CopyTransposed(
const float *Float16);
32 const cVec4 & GetRow(
const int Index)
const;
33 const cVec4 & GetRow0()
const;
34 const cVec4 & GetRow1()
const;
35 const cVec4 & GetRow2()
const;
36 const cVec4 & GetRow3()
const;
38 cVec4 & Row(
const int Index);
44 void SetRow(
const int Index,
const cVec4 &);
45 void SetRow0(
const cVec4 &);
46 void SetRow1(
const cVec4 &);
47 void SetRow2(
const cVec4 &);
48 void SetRow3(
const cVec4 &);
50 void SetRow(
const int Index,
const float X,
const float Y,
const float Z,
const float W);
51 void SetRow0(
const float X,
const float Y,
const float Z,
const float W);
52 void SetRow1(
const float X,
const float Y,
const float Z,
const float W);
53 void SetRow2(
const float X,
const float Y,
const float Z,
const float W);
54 void SetRow3(
const float X,
const float Y,
const float Z,
const float W);
56 const cVec4 GetCol(
const int Index)
const;
57 const cVec4 GetCol0()
const;
58 const cVec4 GetCol1()
const;
59 const cVec4 GetCol2()
const;
60 const cVec4 GetCol3()
const;
62 void SetCol(
const int Index,
const cVec4 &);
63 void SetCol0(
const cVec4 &);
64 void SetCol1(
const cVec4 &);
65 void SetCol2(
const cVec4 &);
66 void SetCol3(
const cVec4 &);
68 void SetCol(
const int Index,
const float X,
const float Y,
const float Z,
const float W);
69 void SetCol0(
const float X,
const float Y,
const float Z,
const float W);
70 void SetCol1(
const float X,
const float Y,
const float Z,
const float W);
71 void SetCol2(
const float X,
const float Y,
const float Z,
const float W);
72 void SetCol3(
const float X,
const float Y,
const float Z,
const float W);
74 void SetElem(
int Row,
int Col,
float Value);
75 float GetElem(
const int Row,
const int Col)
const;
76 float & Elem(
const int Row,
const int Col);
78 const cVec4 & operator [] (
const int Row)
const;
79 cVec4 & operator [] (
const int Row);
81 float operator () (
const int Row,
const int Col)
const;
82 float & operator () (
const int Row,
const int Col);
85 float Determinant()
const;
87 bool operator == (
const cMat4 &)
const;
88 static bool Equals(
const cMat4 &,
const cMat4 &,
const float Eps = cMath::MatrixEpsilon);
90 bool IsZero(
float Eps = cMath::MatrixEpsilon)
const;
91 bool IsIdentity(
float Eps = cMath::MatrixEpsilon)
const;
92 bool IsSymmetric(
float Eps = cMath::MatrixEpsilon )
const;
93 bool IsOrthonormal(
float Eps = cMath::MatrixEpsilon )
const;
95 const cMat4 operator - ()
const;
100 cMat4& operator *= (
const float);
101 cMat4& operator /= (
const float);
103 const cMat4 operator + (
const cMat4 &R)
const;
104 const cMat4 operator - (
const cMat4 &R)
const;
105 const cMat4 operator * (
const cMat4 &R)
const;
106 const cMat4 operator * (
const float)
const;
107 friend const cMat4 operator * (
const float,
const cMat4 &);
108 const cMat4 operator / (
const float)
const;
110 void Add(
const cMat4 &R);
111 void Sub(
const cMat4 &R);
112 void Mul(
const cMat4 &R);
113 void Mul(
const float s);
118 static const cMat4 Mul(
const cMat4 &L,
const float s);
120 const float * ToFloatPtr()
const;
121 float * ToFloatPtr();
123 const cStr ToString(
const int Prec = 2)
const;
125 const cMat3 ToMat3()
const;
126 const cMat3 ToNormalMatrix()
const;
127 const cQuat ToQuat()
const;
129 const cVec3 GetTranslation()
const;
130 void SetTranslation(
const cVec3 & );
132 const cVec3 GetScaling()
const;
133 void SetScaling(
const cVec3 & );
135 cAngles GetRotation()
const;
136 void SetRotation(
const cAngles & );
141 static bool Invert(
const cMat4 &Fm,
cMat4 *To);
142 bool Invert() {
return Invert(*
this,
this); }
144 static const cMat4 Zero;
145 static const cMat4 Identity;
147 static const cMat4 Translation(
const float X,
const float Y);
148 static const cMat4 Translation(
const float X,
const float Y,
const float Z);
149 static const cMat4 Translation(
const cVec2 &XY);
150 static const cMat4 Translation(
const cVec3 &XYZ);
152 static const cMat4 Rotation(
const cVec3 &Axis,
const float Angle);
153 static const cMat4 RotationX(
const float Angle);
154 static const cMat4 RotationY(
const float Angle);
155 static const cMat4 RotationZ(
const float Angle);
156 static const cMat4 RotationXYZ(
const float Pitch,
const float Yaw,
const float Roll);
157 static const cMat4 EulerZYX(
const float eulerX,
const float eulerY,
const float eulerZ);
159 static const cMat4 RotationAt(
const cVec2 &Orig,
const float Angle);
160 static const cMat4 RotationAt(
const cVec3 &Orig,
const cVec3 &Axis,
const float Angle);
162 static const cMat4 Scaling(
const float XYZ);
163 static const cMat4 Scaling(
const float X,
const float Y);
164 static const cMat4 Scaling(
const float X,
const float Y,
const float Z);
168 static const cMat4 ScalingAt(
const float OrigX,
const float OrigY,
const float ScaleXY);
169 static const cMat4 ScalingAt(
const float OrigX,
const float OrigY,
const float ScaleX,
const float ScaleY);
171 static const cMat4 ScalingAt(
const cVec2 &Orig,
const float ScaleXY);
172 static const cMat4 ScalingAt(
const cVec2 &Orig,
const float ScaleX,
const float ScaleY);
175 static const cMat4 ScalingAt(
const cVec3 &Orig,
const float ScaleXYZ);
176 static const cMat4 ScalingAt(
const cVec3 &Orig,
const float ScaleX,
const float ScaleY,
const float ScaleZ);
178 static const cMat4 ScalingAt(
const cVec3 &Orig,
const cVec3 &Dir,
float Scale);
180 static const cMat4 Perspective(
float YFov,
float AspectWtoH,
float Znear,
float Zfar);
181 static const cMat4 PerspectiveInf(
const float YFov,
const float AspectWtoH,
const float Znear);
183 static const cMat4 Ortho(
const float Width,
const float Height,
const float Znear,
const float Zfar);
184 static const cMat4 Ortho(
const float Left,
const float Right,
const float Bottom,
const float Top,
const float Znear,
const float Zfar);
185 static const cMat4 Ortho(
const cBounds &B);
197 static const cMat4 CubeViewProjection(
const cVec3 &Pos,
const int Side,
const float Radius,
const bool GL);
198 static const cMat4 LookAtViewProjection(
const cVec3 &LookFrom,
const cVec3 &LookAt,
const float FovY,
const float AspectYtoH,
const float Znear,
const float Zfar);
200 std::tuple<float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float> __getstate__();
201 void __setstate__(
const std::tuple<float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float>& state);
202 const std::string __repr__()
const;
208inline cMat4::cMat4() {
212inline cMat4::cMat4(
const ERowsCtor,
const cVec4 &Row0,
const cVec4 &Row1,
const cVec4 &Row2,
const cVec4 &Row3) {
220inline cMat4::cMat4(
const EColsCtor,
const cVec4 &Col0,
const cVec4 &Col1,
const cVec4 &Col2,
const cVec4 &Col3) {
221 m_Rows[0].Set(Col0.x, Col1.x, Col2.x, Col3.x);
222 m_Rows[1].Set(Col0.y, Col1.y, Col2.y, Col3.y);
223 m_Rows[2].Set(Col0.z, Col1.z, Col2.z, Col3.z);
224 m_Rows[3].Set(Col0.w, Col1.w, Col2.w, Col3.w);
228inline cMat4::cMat4(
const EZeroCtor) {
236inline cMat4::cMat4(
const EIdentityCtor) {
237 m_Rows[0].Set(1.0f, 0.0f, 0.0f, 0.0f);
238 m_Rows[1].Set(0.0f, 1.0f, 0.0f, 0.0f);
239 m_Rows[2].Set(0.0f, 0.0f, 1.0f, 0.0f);
240 m_Rows[3].Set(0.0f, 0.0f, 0.0f, 1.0f);
244inline cMat4::cMat4(
const cMat3 &Rotation,
const cVec3 &Translation) {
245 m_Rows[0].Set(Rotation.GetRow0(), 0.0f);
246 m_Rows[1].Set(Rotation.GetRow1(), 0.0f);
247 m_Rows[2].Set(Rotation.GetRow2(), 0.0f);
248 m_Rows[3].Set(Translation, 1.0f);
252inline cMat4::cMat4(
const cVec3 &Scaling,
const cVec3 &Translation) {
253 m_Rows[0].Set(Scaling[0], 0.0f, 0.0f, 0.0f);
254 m_Rows[1].Set(0.0f, Scaling[1], 0.0f, 0.0f);
255 m_Rows[2].Set(0.0f, 0.0f, Scaling[2], 0.0f);
256 m_Rows[3].Set(Translation, 1.0f);
260inline cMat4::cMat4(
const float _00,
const float _01,
const float _02,
const float _03,
261 const float _10,
const float _11,
const float _12,
const float _13,
262 const float _20,
const float _21,
const float _22,
const float _23,
263 const float _30,
const float _31,
const float _32,
const float _33) {
264 m_Rows[0].Set(_00, _01, _02, _03);
265 m_Rows[1].Set(_10, _11, _12, _13);
266 m_Rows[2].Set(_20, _21, _22, _23);
267 m_Rows[3].Set(_30, _31, _32, _33);
271inline void cMat4::Copy(
const float *Float16) {
272 m_Rows[0].Set(Float16[0], Float16[1], Float16[2], Float16[3]);
273 m_Rows[1].Set(Float16[4], Float16[5], Float16[6], Float16[7]);
274 m_Rows[2].Set(Float16[8], Float16[9], Float16[10], Float16[11]);
275 m_Rows[3].Set(Float16[12], Float16[13], Float16[14], Float16[15]);
279inline void cMat4::CopyTransposed(
const float *Float16) {
280 m_Rows[0].Set(Float16[0], Float16[4], Float16[8], Float16[12]);
281 m_Rows[1].Set(Float16[1], Float16[5], Float16[9], Float16[13]);
282 m_Rows[2].Set(Float16[2], Float16[6], Float16[10], Float16[14]);
283 m_Rows[3].Set(Float16[3], Float16[7], Float16[11], Float16[15]);
287inline void cMat4::SetZero() {
295inline void cMat4::SetIdentity() {
296 m_Rows[0].Set(1.0f, 0.0f, 0.0f, 0.0f);
297 m_Rows[1].Set(0.0f, 1.0f, 0.0f, 0.0f);
298 m_Rows[2].Set(0.0f, 0.0f, 1.0f, 0.0f);
299 m_Rows[3].Set(0.0f, 0.0f, 0.0f, 1.0f);
303inline const cVec4 & cMat4::GetRow(
const int Index)
const {
304 cAssert(Index >= 0 && Index < 4);
305 return m_Rows[Index];
309inline const cVec4 & cMat4::GetRow0()
const {
314inline const cVec4 & cMat4::GetRow1()
const {
319inline const cVec4 & cMat4::GetRow2()
const {
324inline const cVec4 & cMat4::GetRow3()
const {
329inline cVec4 & cMat4::Row(
const int Index) {
330 cAssert(Index >= 0 && Index < 4);
331 return m_Rows[Index];
335inline cVec4 & cMat4::Row0() {
340inline cVec4 & cMat4::Row1() {
345inline cVec4 & cMat4::Row2() {
350inline cVec4 & cMat4::Row3() {
355inline void cMat4::SetRow(
const int Index,
const cVec4 &r) {
356 cAssert(Index >= 0 && Index < 4);
361inline void cMat4::SetRow0(
const cVec4 &r) {
366inline void cMat4::SetRow1(
const cVec4 &r) {
371inline void cMat4::SetRow2(
const cVec4 &r) {
376inline void cMat4::SetRow3(
const cVec4 &r) {
381inline void cMat4::SetRow(
const int Index,
const float X,
const float Y,
const float Z,
const float W) {
382 cAssert(Index >= 0 && Index < 4);
383 m_Rows[Index].Set(X, Y, Z, W);
387inline void cMat4::SetRow0(
const float X,
const float Y,
const float Z,
const float W) {
388 m_Rows[0].Set(X, Y, Z, W);
392inline void cMat4::SetRow1(
const float X,
const float Y,
const float Z,
const float W) {
393 m_Rows[1].Set(X, Y, Z, W);
397inline void cMat4::SetRow2(
const float X,
const float Y,
const float Z,
const float W) {
398 m_Rows[2].Set(X, Y, Z, W);
402inline void cMat4::SetRow3(
const float X,
const float Y,
const float Z,
const float W) {
403 m_Rows[3].Set(X, Y, Z, W);
407inline const cVec4 cMat4::GetCol(
const int Index)
const {
408 cAssert(Index >= 0 && Index < 4);
409 return cVec4(m_Rows[0][Index], m_Rows[1][Index], m_Rows[2][Index], m_Rows[3][Index]);
413inline const cVec4 cMat4::GetCol0()
const {
414 return cVec4(m_Rows[0].x, m_Rows[1].x, m_Rows[2].x, m_Rows[3].x);
418inline const cVec4 cMat4::GetCol1()
const {
419 return cVec4(m_Rows[0].y, m_Rows[1].y, m_Rows[2].y, m_Rows[3].y);
423inline const cVec4 cMat4::GetCol2()
const {
424 return cVec4(m_Rows[0].z, m_Rows[1].z, m_Rows[2].z, m_Rows[3].z);
428inline const cVec4 cMat4::GetCol3()
const {
429 return cVec4(m_Rows[0].w, m_Rows[1].w, m_Rows[2].w, m_Rows[3].w);
433inline void cMat4::SetCol(
const int Index,
const cVec4 &u) {
434 cAssert(Index >= 0 && Index < 4);
435 m_Rows[0][Index] = u.x;
436 m_Rows[1][Index] = u.y;
437 m_Rows[2][Index] = u.z;
438 m_Rows[3][Index] = u.w;
442inline void cMat4::SetCol0(
const cVec4 &u) {
450inline void cMat4::SetCol1(
const cVec4 &u) {
458inline void cMat4::SetCol2(
const cVec4 &u) {
466inline void cMat4::SetCol3(
const cVec4 &u) {
474inline void cMat4::SetCol(
const int Index,
const float X,
const float Y,
const float Z,
const float W) {
475 cAssert(Index >= 0 && Index < 4);
476 m_Rows[0][Index] = X;
477 m_Rows[1][Index] = Y;
478 m_Rows[2][Index] = Z;
479 m_Rows[3][Index] = W;
483inline void cMat4::SetCol0(
const float X,
const float Y,
const float Z,
const float W) {
491inline void cMat4::SetCol1(
const float X,
const float Y,
const float Z,
const float W) {
499inline void cMat4::SetCol2(
const float X,
const float Y,
const float Z,
const float W) {
507inline void cMat4::SetCol3(
const float X,
const float Y,
const float Z,
const float W) {
515inline void cMat4::SetElem(
int Row,
int Col,
float Value) {
516 cAssert(Row >= 0 && Row < 4);
517 cAssert(Col >= 0 && Col < 4);
518 m_Rows[Row][Col] = Value;
522inline float cMat4::GetElem(
const int Row,
const int Col)
const {
523 cAssert(Row >= 0 && Row < 4);
524 cAssert(Col >= 0 && Col < 4);
525 return m_Rows[Row][Col];
529inline float & cMat4::Elem(
const int Row,
const int Col) {
530 cAssert(Row >= 0 && Row < 4);
531 cAssert(Col >= 0 && Col < 4);
532 return m_Rows[Row][Col];
536inline cVec4 & cMat4::operator [] (
const int Row) {
537 cAssert(Row >= 0 && Row < 4);
542inline const cVec4 & cMat4::operator [] (
const int Row)
const {
543 cAssert(Row >= 0 && Row < 4);
548inline float & cMat4::operator () (
const int Row,
const int Col) {
549 cAssert(Row >= 0 && Row < 4 && Col >= 0 && Col < 4);
550 return m_Rows[Row][Col];
554inline float cMat4::operator () (
const int Row,
const int Col)
const {
555 cAssert(Row >= 0 && Row < 4 && Col >= 0 && Col < 4);
556 return m_Rows[Row][Col];
560inline const cMat4 cMat4::operator - ()
const {
561 return Mul(*
this, -1.0f);
565inline void cMat4::Add(
const cMat4 &R) {
566 float *l = (
float *)
this;
567 const float *r = (
const float *)&R;
569 for(
int i = 0; i < 16; i++) {
575inline cMat4& cMat4::operator += (
const cMat4 &R) {
582 const float *l = (
const float *)&L;
583 const float *r = (
const float *)&R;
586 float *s = (
float *)&S;
588 for(
int i = 0; i < 16; i++) {
596inline const cMat4 cMat4::operator + (
const cMat4 &R)
const {
597 return Add(*
this, R);
601inline void cMat4::Sub(
const cMat4 &R) {
602 float *l = (
float *)
this;
603 const float *r = (
const float *)&R;
605 for(
int i = 0; i < 16; i++) {
611inline cMat4& cMat4::operator -= (
const cMat4 &R) {
618 const float *l = (
const float *)&L;
619 const float *r = (
const float *)&R;
622 float *d = (
float *)&D;
624 for(
int i = 0; i < 16; i++) {
631inline const cMat4 cMat4::operator - (
const cMat4 &R)
const {
632 return Sub(*
this, R);
636inline void cMat4::Mul(
const cMat4 &R) {
637 float *l =
reinterpret_cast<float *
>(
this);
638 const float *r =
reinterpret_cast<const float *
>(&R);
641 for(
int i = 0; i < 4; i++) {
642 for(
int j = 0; j < 4; j++) {
643 t[j] = l[0] * r[0 * 4 + j] + l[1] * r[1 * 4 + j] + l[2] * r[2 * 4 + j] + l[3] * r[3 * 4 + j];
654inline cMat4& cMat4::operator *= (
const cMat4 &R) {
660inline void cMat4::Mul(
const float s) {
661 float *l = (
float *)
this;
662 for(
int i = 0; i < 16; i++) {
668inline cMat4& cMat4::operator *= (
const float s) {
674inline cMat4& cMat4::operator /= (
const float s) {
684 const float *l =
reinterpret_cast<const float *
>(&L);
685 const float *r =
reinterpret_cast<const float *
>(&R);
687 float *m =
reinterpret_cast<float *
>(&M);
689 for(
int i = 0; i < 4; i++) {
690 for(
int j = 0; j < 4; j++) {
691 *m = l[0] * r[0 * 4 + j] + l[1] * r[1 * 4 + j] + l[2] * r[2 * 4 + j] + l[3] * r[3 * 4 + j];
700inline const cMat4 cMat4::operator * (
const cMat4 &R)
const {
701 return Mul(*
this, R);
705inline const cMat4 cMat4::Mul(
const cMat4 &L,
const float s) {
707 float *m = (
float *)&M;
708 const float *l = (
const float *)&L;
710 for(
int i = 0; i < 16; i++) {
717inline const cMat4 cMat4::operator * (
const float s)
const {
718 return Mul(*
this, s);
722inline const cMat4 operator * (
const float s,
const cMat4 &R) {
723 return cMat4::Mul(R, s);
727inline const cMat4 cMat4::operator / (
const float s)
const {
729 return Mul(*
this, is);
733inline float cMat4::Trace()
const {
734 return m_Rows[0][0] + m_Rows[1][1] + m_Rows[2][2] + m_Rows[3][3];
738inline bool cMat4::operator == (
const cMat4 &u)
const {
739 return cMat4::Equals( *
this, u );
743inline bool cMat4::Equals(
const cMat4 &P,
const cMat4 &Q,
const float Eps) {
744 if(cVec4::Equals(P[0], Q[0], Eps) && cVec4::Equals(P[1], Q[1], Eps) && cVec4::Equals(P[2], Q[2], Eps) && cVec4::Equals(P[3], Q[3], Eps)) {
751inline bool cMat4::IsZero(
float Eps)
const {
752 return Equals(*
this, Zero, Eps);
756inline bool cMat4::IsIdentity(
float Eps)
const {
757 return Equals(*
this, Identity, Eps);
761inline bool cMat4::IsSymmetric(
float Eps )
const {
762 if ( !cMath::Equals( m_Rows[ 0 ][ 1 ], m_Rows[ 1 ][ 0 ], Eps ) ) {
765 if ( !cMath::Equals( m_Rows[ 0 ][ 2 ], m_Rows[ 2 ][ 0 ], Eps ) ) {
768 if ( !cMath::Equals( m_Rows[ 1 ][ 2 ], m_Rows[ 2 ][ 1 ], Eps ) ) {
771 if ( !cMath::Equals( m_Rows[ 0 ][ 3 ], m_Rows[ 3 ][ 0 ], Eps ) ) {
774 if ( !cMath::Equals( m_Rows[ 1 ][ 3 ], m_Rows[ 3 ][ 1 ], Eps ) ) {
777 if ( !cMath::Equals( m_Rows[ 2 ][ 3 ], m_Rows[ 3 ][ 2 ], Eps ) ) {
784inline bool cMat4::IsOrthonormal(
float Eps )
const {
785 return cMath::IsOne( Determinant(), Eps );
789inline const float * cMat4::ToFloatPtr()
const {
790 return m_Rows[0].ToFloatPtr();
794inline float * cMat4::ToFloatPtr() {
795 return m_Rows[0].ToFloatPtr();
799inline const cVec3 cMat4::GetTranslation()
const {
800 return m_Rows[3].ToVec3();
804inline void cMat4::SetTranslation(
const cVec3& c ) {
811inline const cVec3 cMat4::GetScaling()
const {
812 return cVec3(m_Rows[0].ToVec3().Length(), m_Rows[1].ToVec3().Length(), m_Rows[2].ToVec3().Length());
816inline void cMat4::SetScaling(
const cVec3& s ) {
823inline const cMat4 cMat4::Transpose(
const cMat4 &M) {
825 for(
int i = 0; i < 4; i++) {
826 T.SetRow(i, M.GetCol(i));
832inline void cMat4::Transpose() {
833 cMath::Swap(m_Rows[0][1], m_Rows[1][0]);
834 cMath::Swap(m_Rows[0][2], m_Rows[2][0]);
835 cMath::Swap(m_Rows[1][2], m_Rows[2][1]);
836 cMath::Swap(m_Rows[0][3], m_Rows[3][0]);
837 cMath::Swap(m_Rows[1][3], m_Rows[3][1]);
838 cMath::Swap(m_Rows[2][3], m_Rows[3][2]);
848 r.x = u.x * T(0, 0) + u.y * T(1, 0) + T(3, 0);
849 r.y = u.x * T(0, 1) + u.y * T(1, 1) + T(3, 1);
850 r.z = u.x * T(0, 2) + u.y * T(1, 2) + T(3, 2);
851 r.w = u.x * T(0, 3) + u.y * T(1, 3) + T(3, 3);
856inline const cVec2 cVec2::TransformCoordinate(
const cVec2 &u,
const cMat4 &T) {
858 r.x = u.x * T(0, 0) + u.y * T(1, 0) + T(3, 0);
859 r.y = u.x * T(0, 1) + u.y * T(1, 1) + T(3, 1);
860 float w = u.x * T(0, 3) + u.y * T(1, 3) + T(3, 3);
870inline void cVec2::TransformCoordinate(
const cMat4 &T) {
871 *
this = TransformCoordinate(*
this, T);
875inline const cVec2 cVec2::TransformNormal(
const cVec2 &u,
const cMat4 &T) {
877 r.x = u.x * T(0, 0) + u.y * T(1, 0);
878 r.y = u.x * T(0, 1) + u.y * T(1, 1);
883inline void cVec2::TransformNormal(
const cMat4 &T) {
884 *
this = TransformNormal(*
this, T);
894 t.x = u.x * M[0][0] + u.y * M[1][0] + u.z * M[2][0] + M[3][0];
895 t.y = u.x * M[0][1] + u.y * M[1][1] + u.z * M[2][1] + M[3][1];
896 t.z = u.x * M[0][2] + u.y * M[1][2] + u.z * M[2][2] + M[3][2];
897 t.w = u.x * M[0][3] + u.y * M[1][3] + u.z * M[2][3] + M[3][3];
902inline const cVec3 cVec3::TransformCoordinate(
const cVec3 &u,
const cMat4 &T) {
904 r.x = u.x * T(0, 0) + u.y * T(1, 0) + u.z * T(2, 0) + T(3, 0);
905 r.y = u.x * T(0, 1) + u.y * T(1, 1) + u.z * T(2, 1) + T(3, 1);
906 r.z = u.x * T(0, 2) + u.y * T(1, 2) + u.z * T(2, 2) + T(3, 2);
907 float w = u.x * T(0, 3) + u.y * T(1, 3) + u.z * T(2, 3) + T(3, 3);
918inline void cVec3::TransformCoordinate(
const cMat4 &T) {
919 *
this = TransformCoordinate(*
this, T);
923inline const cVec3 cVec3::TransformNormal(
const cVec3 &u,
const cMat4 &T) {
925 r.x = u.x * T(0, 0) + u.y * T(1, 0) + u.z * T(2, 0);
926 r.y = u.x * T(0, 1) + u.y * T(1, 1) + u.z * T(2, 1);
927 r.z = u.x * T(0, 2) + u.y * T(1, 2) + u.z * T(2, 2);
932inline void cVec3::TransformNormal(
const cMat4 &T) {
933 *
this = TransformNormal(*
this, T);
937inline void cVec3::TransformNormalTransposed(
const cMat4 &T) {
939 x = u.x * T(0, 0) + u.y * T(0, 1) + u.z * T(0, 2);
940 y = u.x * T(1, 0) + u.y * T(1, 1) + u.z * T(1, 2);
941 z = u.x * T(2, 0) + u.y * T(2, 1) + u.z * T(2, 2);
951 r.x = u.x * T(0, 0) + u.y * T(1, 0) + u.z * T(2, 0) + u.w * T(3, 0);
952 r.y = u.x * T(0, 1) + u.y * T(1, 1) + u.z * T(2, 1) + u.w * T(3, 1);
953 r.z = u.x * T(0, 2) + u.y * T(1, 2) + u.z * T(2, 2) + u.w * T(3, 2);
954 r.w = u.x * T(0, 3) + u.y * T(1, 3) + u.z * T(2, 3) + u.w * T(3, 3);
959inline void cVec4::Transform(
const cMat4 &T) {
960 *
this = Transform(*
this, T);
964inline void cVec4::operator *= (
const cMat4 &T) {
965 *
this = Transform(*
this, T);
969inline const cVec4 cVec4::operator * (
const cMat4 &T)
const {
970 return Transform(*
this, T);
978inline const cMat4 cMat3::ToMat4()
const {
979 return cMat4(*
this, cVec3::Zero);
983inline const cMat3 cMat4::ToMat3()
const {
984 return cMat3(cMat3::RowsCtor, m_Rows[0].ToVec3(), m_Rows[1].ToVec3(), m_Rows[2].ToVec3());
990::std::ostream& operator<<( ::std::ostream&,
const cMat4& );
The 3D-matrix, refer it as coat::mat3 in the Core API.
Definition cMat3.h:6
The 4D-matrix, refer it as coat::mat4 in the Core API.
Definition cMat4.h:6
The 2D-vector, refer it as coat::vec2 in the Core API.
Definition cVec2.h:9
The 3D-vector, refer it as coat::vec3 in the Core API.
Definition cVec3.h:10
The 4D-vector, refer it as coat::vec4 in the Core API.
Definition cVec4.h:9