EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Ga::GaMat4x4 Class Reference

#include "GaTypes.h"

Public Member Functions

GaExpInl GaMat4x4 ()
 
GaExpInl GaMat4x4 (const GaFloat *v)
 
GaExpInl GaMat4x4 (GaFloat m00, GaFloat m01, GaFloat m02, GaFloat m03, GaFloat m10, GaFloat m11, GaFloat m12, GaFloat m13, GaFloat m20, GaFloat m21, GaFloat m22, GaFloat m23, GaFloat m30, GaFloat m31, GaFloat m32, GaFloat m33)
 
GaExpInl GaMat4x4 (const GaVec3 &p, const GaQuat &q)
 
GaExpInl GaMat4x4 operator* (const GaMat4x4 &oth) const
 
GaExpInl GaFloatoperator[] (GaUint i)
 
GaExpInl const GaFloat *const operator[] (GaUint i) const
 
GaExpInl GaVec3 operator* (const GaVec3 &v) const
 
GaExpInl void toFloatMatrix (float *o)
 
GaExpInl GaMat4x4 operator* (GaFloat s)
 
GaMat4x4 inverse () const
 
GaMat4x4 adjoint () const
 
GaFloat determinant () const
 

Public Attributes

GaFloat m [4][4]
 

Detailed Description

Definition at line 332 of file GaTypes.h.

Constructor & Destructor Documentation

GaExpInl Ga::GaMat4x4::GaMat4x4 ( )
inline

Definition at line 335 of file GaTypes.h.

Referenced by adjoint().

335 {}

Here is the caller graph for this function:

GaExpInl Ga::GaMat4x4::GaMat4x4 ( const GaFloat v)
inline

Definition at line 337 of file GaTypes.h.

338  {
339  m[0][0] = v[ 0]; m[0][1] = v[ 1]; m[0][2] = v[ 2]; m[0][3] = v[ 3];
340  m[1][0] = v[ 4]; m[1][1] = v[ 5]; m[1][2] = v[ 6]; m[1][3] = v[ 7];
341  m[2][0] = v[ 8]; m[2][1] = v[ 9]; m[2][2] = v[10]; m[2][3] = v[11];
342  m[3][0] = v[12]; m[3][1] = v[13]; m[3][2] = v[14]; m[3][3] = v[15];
343  }
GaFloat m[4][4]
Definition: GaTypes.h:440
GaExpInl Ga::GaMat4x4::GaMat4x4 ( GaFloat  m00,
GaFloat  m01,
GaFloat  m02,
GaFloat  m03,
GaFloat  m10,
GaFloat  m11,
GaFloat  m12,
GaFloat  m13,
GaFloat  m20,
GaFloat  m21,
GaFloat  m22,
GaFloat  m23,
GaFloat  m30,
GaFloat  m31,
GaFloat  m32,
GaFloat  m33 
)
inline

Definition at line 345 of file GaTypes.h.

349  {
350  m[0][0] = m00; m[0][1] = m01; m[0][2] = m02; m[0][3] = m03;
351  m[1][0] = m10; m[1][1] = m11; m[1][2] = m12; m[1][3] = m13;
352  m[2][0] = m20; m[2][1] = m21; m[2][2] = m22; m[2][3] = m23;
353  m[3][0] = m30; m[3][1] = m31; m[3][2] = m32; m[3][3] = m33;
354  }
GaFloat m[4][4]
Definition: GaTypes.h:440
GaExpInl Ga::GaMat4x4::GaMat4x4 ( const GaVec3 p,
const GaQuat q 
)
inline

Definition at line 356 of file GaTypes.h.

References Ga::GaVec3::x, Ga::GaVec3::y, and Ga::GaVec3::z.

357  {
358  GaMat3x3 rot(q);
359 
360  m[0][0] = rot[0][0]; m[0][1] = rot[0][1]; m[0][2] = rot[0][2]; m[0][3] = p.x;
361  m[1][0] = rot[1][0]; m[1][1] = rot[1][1]; m[1][2] = rot[1][2]; m[1][3] = p.y;
362  m[2][0] = rot[2][0]; m[2][1] = rot[2][1]; m[2][2] = rot[2][2]; m[2][3] = p.z;
363  m[3][0] = 0.0; m[3][1] = 0.0; m[3][2] = 0.0; m[3][3] = 1.0;
364  }
GaFloat m[4][4]
Definition: GaTypes.h:440

Member Function Documentation

GaMat4x4 GaMat4x4::adjoint ( ) const

Definition at line 259 of file GaTypes.cpp.

References GaMat4x4(), and matrix_minor().

Referenced by inverse().

260 {
261  return GaMat4x4
262  (
263  matrix_minor(*this, 1, 2, 3, 1, 2, 3),
264  -matrix_minor(*this, 0, 2, 3, 1, 2, 3),
265  matrix_minor(*this, 0, 1, 3, 1, 2, 3),
266  -matrix_minor(*this, 0, 1, 2, 1, 2, 3),
267 
268  -matrix_minor(*this, 1, 2, 3, 0, 2, 3),
269  matrix_minor(*this, 0, 2, 3, 0, 2, 3),
270  -matrix_minor(*this, 0, 1, 3, 0, 2, 3),
271  matrix_minor(*this, 0, 1, 2, 0, 2, 3),
272 
273  matrix_minor(*this, 1, 2, 3, 0, 1, 3),
274  -matrix_minor(*this, 0, 2, 3, 0, 1, 3),
275  matrix_minor(*this, 0, 1, 3, 0, 1, 3),
276  -matrix_minor(*this, 0, 1, 2, 0, 1, 3),
277 
278  -matrix_minor(*this, 1, 2, 3, 0, 1, 2),
279  matrix_minor(*this, 0, 2, 3, 0, 1, 2),
280  -matrix_minor(*this, 0, 1, 3, 0, 1, 2),
281  matrix_minor(*this, 0, 1, 2, 0, 1, 2)
282  );
283 }
GaFloat matrix_minor(const GaMat4x4 &m, GaUint r0, GaUint r1, GaUint r2, GaUint c0, GaUint c1, GaUint c2)
Definition: GaTypes.cpp:48
GaExpInl GaMat4x4()
Definition: GaTypes.h:335

Here is the call graph for this function:

Here is the caller graph for this function:

GaFloat GaMat4x4::determinant ( ) const

Definition at line 285 of file GaTypes.cpp.

References m, and matrix_minor().

Referenced by inverse().

286 {
287  return m[0][0] * matrix_minor(*this, 1, 2, 3, 1, 2, 3) -
288  m[0][1] * matrix_minor(*this, 1, 2, 3, 0, 2, 3) +
289  m[0][2] * matrix_minor(*this, 1, 2, 3, 0, 1, 3) -
290  m[0][3] * matrix_minor(*this, 1, 2, 3, 0, 1, 2);
291 }
GaFloat m[4][4]
Definition: GaTypes.h:440
GaFloat matrix_minor(const GaMat4x4 &m, GaUint r0, GaUint r1, GaUint r2, GaUint c0, GaUint c1, GaUint c2)
Definition: GaTypes.cpp:48

Here is the call graph for this function:

Here is the caller graph for this function:

GaMat4x4 GaMat4x4::inverse ( ) const

Definition at line 293 of file GaTypes.cpp.

References adjoint(), and determinant().

294 {
295  return adjoint() * (1.0f / determinant());
296 }
GaFloat determinant() const
Definition: GaTypes.cpp:285
GaMat4x4 adjoint() const
Definition: GaTypes.cpp:259

Here is the call graph for this function:

GaExpInl GaMat4x4 Ga::GaMat4x4::operator* ( const GaMat4x4 oth) const
inline

Definition at line 366 of file GaTypes.h.

References m.

367  {
368  GaMat4x4 o;
369 
370  o.m[0][0] = m[0][0] * oth.m[0][0] + m[0][1] * oth.m[1][0] + m[0][2] * oth.m[2][0] + m[0][3] * oth.m[3][0];
371  o.m[0][1] = m[0][0] * oth.m[0][1] + m[0][1] * oth.m[1][1] + m[0][2] * oth.m[2][1] + m[0][3] * oth.m[3][1];
372  o.m[0][2] = m[0][0] * oth.m[0][2] + m[0][1] * oth.m[1][2] + m[0][2] * oth.m[2][2] + m[0][3] * oth.m[3][2];
373  o.m[0][3] = m[0][0] * oth.m[0][3] + m[0][1] * oth.m[1][3] + m[0][2] * oth.m[2][3] + m[0][3] * oth.m[3][3];
374 
375  o.m[1][0] = m[1][0] * oth.m[0][0] + m[1][1] * oth.m[1][0] + m[1][2] * oth.m[2][0] + m[1][3] * oth.m[3][0];
376  o.m[1][1] = m[1][0] * oth.m[0][1] + m[1][1] * oth.m[1][1] + m[1][2] * oth.m[2][1] + m[1][3] * oth.m[3][1];
377  o.m[1][2] = m[1][0] * oth.m[0][2] + m[1][1] * oth.m[1][2] + m[1][2] * oth.m[2][2] + m[1][3] * oth.m[3][2];
378  o.m[1][3] = m[1][0] * oth.m[0][3] + m[1][1] * oth.m[1][3] + m[1][2] * oth.m[2][3] + m[1][3] * oth.m[3][3];
379 
380  o.m[2][0] = m[2][0] * oth.m[0][0] + m[2][1] * oth.m[1][0] + m[2][2] * oth.m[2][0] + m[2][3] * oth.m[3][0];
381  o.m[2][1] = m[2][0] * oth.m[0][1] + m[2][1] * oth.m[1][1] + m[2][2] * oth.m[2][1] + m[2][3] * oth.m[3][1];
382  o.m[2][2] = m[2][0] * oth.m[0][2] + m[2][1] * oth.m[1][2] + m[2][2] * oth.m[2][2] + m[2][3] * oth.m[3][2];
383  o.m[2][3] = m[2][0] * oth.m[0][3] + m[2][1] * oth.m[1][3] + m[2][2] * oth.m[2][3] + m[2][3] * oth.m[3][3];
384 
385  o.m[3][0] = m[3][0] * oth.m[0][0] + m[3][1] * oth.m[1][0] + m[3][2] * oth.m[2][0] + m[3][3] * oth.m[3][0];
386  o.m[3][1] = m[3][0] * oth.m[0][1] + m[3][1] * oth.m[1][1] + m[3][2] * oth.m[2][1] + m[3][3] * oth.m[3][1];
387  o.m[3][2] = m[3][0] * oth.m[0][2] + m[3][1] * oth.m[1][2] + m[3][2] * oth.m[2][2] + m[3][3] * oth.m[3][2];
388  o.m[3][3] = m[3][0] * oth.m[0][3] + m[3][1] * oth.m[1][3] + m[3][2] * oth.m[2][3] + m[3][3] * oth.m[3][3];
389 
390  return o;
391  }
GaFloat m[4][4]
Definition: GaTypes.h:440
GaExpInl GaMat4x4()
Definition: GaTypes.h:335
GaExpInl GaVec3 Ga::GaMat4x4::operator* ( const GaVec3 v) const
inline

Definition at line 405 of file GaTypes.h.

References Ga::GaVec3::x, Ga::GaVec3::y, and Ga::GaVec3::z.

406  {
407  GaFloat w = 1.0f / ( m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3] );
408 
409  GaVec3 r(
410  ( m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] ) * w,
411  ( m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] ) * w,
412  ( m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] ) * w );
413 
414  return r;
415  }
GaFloat m[4][4]
Definition: GaTypes.h:440
double GaFloat
Definition: GaPreReqs.h:69
GaExpInl GaMat4x4 Ga::GaMat4x4::operator* ( GaFloat  s)
inline

Definition at line 425 of file GaTypes.h.

426  {
427  return GaMat4x4
428  (
429  s*m[0][0], s*m[0][1], s*m[0][2], s*m[0][3],
430  s*m[1][0], s*m[1][1], s*m[1][2], s*m[1][3],
431  s*m[2][0], s*m[2][1], s*m[2][2], s*m[2][3],
432  s*m[3][0], s*m[3][1], s*m[3][2], s*m[3][3]
433  );
434  }
GaFloat m[4][4]
Definition: GaTypes.h:440
GaExpInl GaMat4x4()
Definition: GaTypes.h:335
GaExpInl GaFloat* Ga::GaMat4x4::operator[] ( GaUint  i)
inline

Definition at line 393 of file GaTypes.h.

394  {
395  assert(i < 4 && "GaMax4x4: subscript out of range");
396  return m[i];
397  }
GaFloat m[4][4]
Definition: GaTypes.h:440
GaExpInl const GaFloat* const Ga::GaMat4x4::operator[] ( GaUint  i) const
inline

Definition at line 399 of file GaTypes.h.

400  {
401  assert(i < 4 && "GaMax4x4: subscript out of range");
402  return m[i];
403  }
GaFloat m[4][4]
Definition: GaTypes.h:440
GaExpInl void Ga::GaMat4x4::toFloatMatrix ( float *  o)
inline

Definition at line 417 of file GaTypes.h.

418  {
419  o[0] = m[0][0]; o[4] = m[0][1]; o[8] = m[0][2]; o[12] = m[0][3];
420  o[1] = m[1][0]; o[5] = m[1][1]; o[9] = m[1][2]; o[13] = m[1][3];
421  o[2] = m[2][0]; o[6] = m[2][1]; o[10] = m[2][2]; o[14] = m[2][3];
422  o[3] = m[3][0]; o[7] = m[3][1]; o[11] = m[3][2]; o[15] = m[3][3];
423  }
GaFloat m[4][4]
Definition: GaTypes.h:440

Member Data Documentation

GaFloat Ga::GaMat4x4::m[4][4]

Definition at line 440 of file GaTypes.h.

Referenced by determinant(), and operator*().


The documentation for this class was generated from the following files: