TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::Matrix4 Class Reference

#include <Matrix4.h>

Public Member Functions

 Matrix4 (const Any &any)
 
Any toAny () const
 
 Matrix4 (float r1c1, float r1c2, float r1c3, float r1c4, float r2c1, float r2c2, float r2c3, float r2c4, float r3c1, float r3c2, float r3c3, float r3c4, float r4c1, float r4c2, float r4c3, float r4c4)
 
 Matrix4 (const float *init)
 
 Matrix4 (const class Matrix3 &upper3x3, const class Vector3 &lastCol=Vector3::zero())
 
 Matrix4 (const class CoordinateFrame &c)
 
 Matrix4 (const double *init)
 
 Matrix4 ()
 
class CoordinateFrame approxCoordinateFrame () const
 
void getPerspectiveProjectionParameters (double &left, double &right, double &bottom, double &top, double &nearval, double &farval, float updirection=-1.0f) const
 
float * operator[] (int r)
 
const float * operator[] (int r) const
 
 operator float * ()
 
 operator const float * () const
 
Matrix4 operator* (const Matrix4 &other) const
 
Matrix4 operator+ (const Matrix4 &other) const
 
class Matrix3 upper3x3 () const
 
class Matrix2 upper2x2 () const
 
class Vector3 homoMul (const class Vector3 &v, float w) const
 
void setRow (int r, const class Vector4 &v)
 
void setColumn (int c, const Vector4 &v)
 
const Vector4row (int r) const
 
Vector4 column (int c) const
 
Matrix4 operator* (const float s) const
 
Vector4 operator* (const Vector4 &vector) const
 
Matrix4 transpose () const
 
bool operator!= (const Matrix4 &other) const
 
bool operator== (const Matrix4 &other) const
 
float determinant () const
 
Matrix4 inverse () const
 
Matrix4 adjoint () const
 
Matrix4 cofactor () const
 
void serialize (class BinaryOutput &b) const
 
void deserialize (class BinaryInput &b)
 
std::string toString () const
 

Static Public Member Functions

static Matrix4 diagonal (float e00, float e11, float e22, float e33)
 
static const Matrix4identity ()
 
static const Matrix4zero ()
 
static Matrix4 orthogonalProjection (float left, float right, float bottom, float top, float nearval, float farval, float upDirection=-1.0f)
 
static Matrix4 orthogonalProjection (const class Rect2D &rect, float nearval, float farval, float upDirection=-1.0f)
 
static Matrix4 perspectiveProjection (double left, double right, double bottom, double top, double nearval, double farval, float upDirection=-1.0f)
 
static Matrix4 scale (const Vector3 &v)
 
static Matrix4 scale (float x, float y, float z)
 
static Matrix4 scale (float s)
 
static Matrix4 translation (const Vector3 &v)
 
static Matrix4 translation (float x, float y, float z)
 
static Matrix4 yawDegrees (float deg)
 
static Matrix4 pitchDegrees (float deg)
 
static Matrix4 rollDegrees (float deg)
 

Private Member Functions

float subDeterminant (int excludeRow, int excludeCol) const
 
bool operator< (const Matrix4 &) const
 
bool operator> (const Matrix4 &) const
 
bool operator<= (const Matrix4 &) const
 
bool operator>= (const Matrix4 &) const
 

Private Attributes

float elt [4][4]
 

Detailed Description

A 4x4 matrix. Do not subclass. Data is initialized to 0 when default constructed.

See also
G3D::CoordinateFrame, G3D::Matrix3, G3D::Quat

Constructor & Destructor Documentation

G3D::Matrix4::Matrix4 ( const Any any)
explicit

Must be in one of the following forms:

26  {
27  any.verifyNameBeginsWith("Matrix4", "CFrame", "CoordinateFrame");
28  any.verifyType(Any::ARRAY);
29 
30  const std::string& name = any.name();
31  if (name == "Matrix4") {
32  any.verifySize(16);
33 
34  for (int r = 0; r < 4; ++r) {
35  for (int c = 0; c < 4; ++c) {
36  elt[r][c] = any[r * 4 + c];
37  }
38  }
39  } else if (name == "Matrix4::scale") {
40  if (any.size() == 1) {
41  *this = scale(any[0].floatValue());
42  } else if (any.size() == 3) {
43  *this = scale(any[0], any[1], any[2]);
44  } else {
45  any.verify(false, "Matrix4::scale() takes either 1 or 3 arguments");
46  }
47  } else if (name == "Matrix4::rollDegrees") {
48  any.verifySize(1);
49  *this = rollDegrees(any[0].floatValue());
50  } else if (name == "Matrix4::yawDegrees") {
51  any.verifySize(1);
52  *this = yawDegrees(any[0].floatValue());
53  } else if (name == "Matrix4::pitchDegrees") {
54  any.verifySize(1);
55  *this = pitchDegrees(any[0].floatValue());
56  } else if (name == "Matrix4::translation") {
57  if (any.size() == 3) {
58  *this = translation(any[0], any[1], any[2]);
59  } else {
60  any.verify(false, "Matrix4::translation() requires 3 arguments");
61  }
62  } else if (name == "Matrix4::diagonal") {
63  any.verifySize(4);
64  *this = diagonal(any[0], any[1], any[2], any[3]);
65  } else if (name == "Matrix4::identity") {
66  *this = identity();
67  } else if (beginsWith(name, "CFrame") || beginsWith(name, "CoordinateFrame")) {
68  *this = CFrame(any);
69  } else {
70  any.verify(false, "Expected Matrix4 constructor");
71  }
72 }
bool beginsWith(const std::string &test, const std::string &pattern)
Returns true if the test string begins with the pattern string.
Definition: stringutils.cpp:81
static Matrix4 diagonal(float e00, float e11, float e22, float e33)
Definition: Matrix4.h:92
static Matrix4 scale(const Vector3 &v)
Definition: Matrix4.h:239
static Matrix4 translation(const Vector3 &v)
Definition: Matrix4.h:257
class CoordinateFrame CFrame
Definition: Box2D.h:22
bool any(float x)
Definition: g3dmath.h:424
static Matrix4 rollDegrees(float deg)
Definition: Matrix4.h:274
Definition: Any.h:187
static Matrix4 yawDegrees(float deg)
Definition: Matrix4.h:266
static const Matrix4 & identity()
Definition: Matrix4.cpp:87
float elt[4][4]
Definition: Matrix4.h:39
static Matrix4 pitchDegrees(float deg)
Definition: Matrix4.h:270

+ Here is the call graph for this function:

G3D::Matrix4::Matrix4 ( float  r1c1,
float  r1c2,
float  r1c3,
float  r1c4,
float  r2c1,
float  r2c2,
float  r2c3,
float  r2c4,
float  r3c1,
float  r3c2,
float  r3c3,
float  r3c4,
float  r4c1,
float  r4c2,
float  r4c3,
float  r4c4 
)
277  {
278  elt[0][0] = r1c1; elt[0][1] = r1c2; elt[0][2] = r1c3; elt[0][3] = r1c4;
279  elt[1][0] = r2c1; elt[1][1] = r2c2; elt[1][2] = r2c3; elt[1][3] = r2c4;
280  elt[2][0] = r3c1; elt[2][1] = r3c2; elt[2][2] = r3c3; elt[2][3] = r3c4;
281  elt[3][0] = r4c1; elt[3][1] = r4c2; elt[3][2] = r4c3; elt[3][3] = r4c4;
282 }
float elt[4][4]
Definition: Matrix4.h:39
G3D::Matrix4::Matrix4 ( const float *  init)

init should be row major.

287  {
288  for (int r = 0; r < 4; ++r) {
289  for (int c = 0; c < 4; ++c) {
290  elt[r][c] = init[r * 4 + c];
291  }
292  }
293 }
float elt[4][4]
Definition: Matrix4.h:39
G3D::Matrix4::Matrix4 ( const class Matrix3 upper3x3,
const class Vector3 lastCol = Vector3::zero() 
)

a is the upper left 3x3 submatrix and b is the upper right 3x1 submatrix. The last row of the created matrix is (0,0,0,1).

G3D::Matrix4::Matrix4 ( const class CoordinateFrame c)
107  {
108  for (int r = 0; r < 3; ++r) {
109  for (int c = 0; c < 3; ++c) {
110  elt[r][c] = cframe.rotation[r][c];
111  }
112  elt[r][3] = cframe.translation[r];
113  }
114  elt[3][0] = 0.0f;
115  elt[3][1] = 0.0f;
116  elt[3][2] = 0.0f;
117  elt[3][3] = 1.0f;
118 }
float elt[4][4]
Definition: Matrix4.h:39
G3D::Matrix4::Matrix4 ( const double *  init)
296  {
297  for (int r = 0; r < 4; ++r) {
298  for (int c = 0; c < 4; ++c) {
299  elt[r][c] = (float)init[r * 4 + c];
300  }
301  }
302 }
float elt[4][4]
Definition: Matrix4.h:39
G3D::Matrix4::Matrix4 ( )

Matrix4::zero()

305  {
306  for (int r = 0; r < 4; ++r) {
307  for (int c = 0; c < 4; ++c) {
308  elt[r][c] = 0;
309  }
310  }
311 }
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the caller graph for this function:

Member Function Documentation

Matrix4 G3D::Matrix4::adjoint ( ) const

Transpose of the cofactor matrix (used in computing the inverse). Note: This is in fact only one type of adjoint. More generally, an adjoint of a matrix is any mapping of a matrix which possesses certain properties. This returns the so-called adjugate or classical adjoint.

431  {
432  return cofactor().transpose();
433 }
Matrix4 transpose() const
Definition: Matrix4.cpp:386
Matrix4 cofactor() const
Definition: Matrix4.cpp:449

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CoordinateFrame G3D::Matrix4::approxCoordinateFrame ( ) const

Produces an RT transformation that nearly matches this Matrix4. Because a Matrix4 may not be precisely a rotation and translation, this may introduce error.

507  {
508  CoordinateFrame cframe;
509 
510  for (int r = 0; r < 3; ++r) {
511  for (int c = 0; c < 3; ++c) {
512  cframe.rotation[r][c] = elt[r][c];
513  }
514  cframe.translation[r] = elt[r][3];
515  }
516 
517  // Ensure that the rotation matrix is orthonormal
518  cframe.rotation.orthonormalize();
519 
520  return cframe;
521 }
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Matrix4 G3D::Matrix4::cofactor ( ) const
449  {
450  Matrix4 out;
451 
452  // We'll use i to incrementally compute -1 ^ (r+c)
453  int i = 1;
454 
455  for (int r = 0; r < 4; ++r) {
456  for (int c = 0; c < 4; ++c) {
457  // Compute the determinant of the 3x3 submatrix
458  float det = subDeterminant(r, c);
459  out.elt[r][c] = i * det;
460  i = -i;
461  }
462  i = -i;
463  }
464 
465  return out;
466 }
float subDeterminant(int excludeRow, int excludeCol) const
Definition: Matrix4.cpp:469
Matrix4()
Definition: Matrix4.cpp:305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Vector4 G3D::Matrix4::column ( int  c) const
333  {
334  Vector4 v;
335  for (int r = 0; r < 4; ++r) {
336  v[r] = elt[r][c];
337  }
338  return v;
339 }
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the caller graph for this function:

void G3D::Matrix4::deserialize ( class BinaryInput b)
533  {
534  for (int r = 0; r < 4; ++r) {
535  for (int c = 0; c < 4; ++c) {
536  elt[r][c] = b.readFloat32();
537  }
538  }
539 }
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the call graph for this function:

float G3D::Matrix4::determinant ( ) const
424  {
425  // Determinant is the dot product of the first row and the first row
426  // of cofactors (i.e. the first col of the adjoint matrix)
427  return cofactor().row(0).dot(row(0));
428 }
Matrix4 cofactor() const
Definition: Matrix4.cpp:449
const Vector4 & row(int r) const
Definition: Matrix4.cpp:328
float dot(const Vector4 &rkVector) const
Definition: Vector4.h:659

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Matrix4 G3D::Matrix4::diagonal ( float  e00,
float  e11,
float  e22,
float  e33 
)
inlinestatic
92  {
93  return Matrix4(e00, 0, 0, 0,
94  0, e11, 0, 0,
95  0, 0, e22, 0,
96  0, 0, 0, e33);
97  }
Matrix4()
Definition: Matrix4.cpp:305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void G3D::Matrix4::getPerspectiveProjectionParameters ( double &  left,
double &  right,
double &  bottom,
double &  top,
double &  nearval,
double &  farval,
float  updirection = -1.0f 
) const

If this is a perspective projection matrix created by Matrix4::perspectiveProjection, extract its parameters.

Uses double precision because the operations involved in projection involve divisions that can significantly impact precision.

233  {
234 
235  debugAssertM(abs(upDirection) == 1.0f, "upDirection must be -1 or +1");
236 
237  double x = elt[0][0];
238  double y = elt[1][1] * upDirection;
239  double a = elt[0][2];
240  double b = elt[1][2] * upDirection;
241  double c = elt[2][2];
242  double d = elt[2][3];
243 
244  // Verify that this really is a projection matrix
245  debugAssertM(elt[3][2] == -1, "Not a projection matrix");
246  debugAssertM(elt[0][1] == 0, "Not a projection matrix");
247  debugAssertM(elt[0][3] == 0, "Not a projection matrix");
248  debugAssertM(elt[1][3] == 0, "Not a projection matrix");
249  debugAssertM(elt[3][3] == 0, "Not a projection matrix");
250  debugAssertM(elt[1][0] == 0, "Not a projection matrix");
251  debugAssertM(elt[2][0] == 0, "Not a projection matrix");
252  debugAssertM(elt[2][1] == 0, "Not a projection matrix");
253  debugAssertM(elt[3][0] == 0, "Not a projection matrix");
254  debugAssertM(elt[3][1] == 0, "Not a projection matrix");
255 
256  if (c == -1) {
257  farval = finf();
258  nearval = -d / 2.0;
259  } else {
260  nearval = d * ((c - 1.0) / (c + 1.0) - 1.0) / (-2.0 * (c - 1.0) / (c + 1.0));
261  farval = nearval * ((c - 1.0) / (c + 1.0));
262  }
263 
264 
265  left = (a - 1.0) * nearval / x;
266  right = 2.0 * nearval / x + left;
267 
268  bottom = (b - 1.0) * nearval / y;
269  top = 2.0 * nearval / y + bottom;
270 }
float finf()
Definition: g3dmath.cpp:71
double abs(double fValue)
Definition: g3dmath.h:617
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
G3D::int16 y
Definition: Vector2int16.h:38
bool left(const int *a, const int *b, const int *c)
Definition: RecastContour.cpp:487
float elt[4][4]
Definition: Matrix4.h:39
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

Vector3 G3D::Matrix4::homoMul ( const class Vector3 v,
float  w 
) const

Homogeneous multiplication. Let k = M * [v w]^T. result = k.xyz() / k.w

368  {
369  Vector4 r = (*this) * Vector4(v, w);
370  return r.xyz() * (1.0f / r.w);
371 }

+ Here is the call graph for this function:

const Matrix4 & G3D::Matrix4::identity ( )
static
87  {
88  static Matrix4 m(
89  1, 0, 0, 0,
90  0, 1, 0, 0,
91  0, 0, 1, 0,
92  0, 0, 0, 1);
93  return m;
94 }
Matrix4()
Definition: Matrix4.cpp:305

+ Here is the caller graph for this function:

Matrix4 G3D::Matrix4::inverse ( ) const
436  {
437  // Inverse = adjoint / determinant
438 
439  Matrix4 A = adjoint();
440 
441  // Determinant is the dot product of the first row and the first row
442  // of cofactors (i.e. the first col of the adjoint matrix)
443  float det = A.column(0).dot(row(0));
444 
445  return A * (1.0f / det);
446 }
const Vector4 & row(int r) const
Definition: Matrix4.cpp:328
Matrix4()
Definition: Matrix4.cpp:305
Matrix4 adjoint() const
Definition: Matrix4.cpp:431

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

G3D::Matrix4::operator const float * ( ) const
inline
142  {
143  return (const float*)&elt[0][0];
144  }
float elt[4][4]
Definition: Matrix4.h:39
G3D::Matrix4::operator float * ( )
inline

Returns a row-major pointer.

138  {
139  return (float*)&elt[0][0];
140  }
float elt[4][4]
Definition: Matrix4.h:39
bool G3D::Matrix4::operator!= ( const Matrix4 other) const
398  {
399  return ! (*this == other);
400 }
Matrix4 G3D::Matrix4::operator* ( const Matrix4 other) const
342  {
343  Matrix4 result;
344  for (int r = 0; r < 4; ++r) {
345  for (int c = 0; c < 4; ++c) {
346  for (int i = 0; i < 4; ++i) {
347  result.elt[r][c] += elt[r][i] * other.elt[i][c];
348  }
349  }
350  }
351 
352  return result;
353 }
Matrix4()
Definition: Matrix4.cpp:305
float elt[4][4]
Definition: Matrix4.h:39
Matrix4 G3D::Matrix4::operator* ( const float  s) const
356  {
357  Matrix4 result;
358  for (int r = 0; r < 4; ++r) {
359  for (int c = 0; c < 4; ++c) {
360  result.elt[r][c] = elt[r][c] * s;
361  }
362  }
363 
364  return result;
365 }
Matrix4()
Definition: Matrix4.cpp:305
float elt[4][4]
Definition: Matrix4.h:39
Vector4 G3D::Matrix4::operator* ( const Vector4 vector) const
374  {
375  Vector4 result(0,0,0,0);
376  for (int r = 0; r < 4; ++r) {
377  for (int c = 0; c < 4; ++c) {
378  result[r] += elt[r][c] * vector[c];
379  }
380  }
381 
382  return result;
383 }
float elt[4][4]
Definition: Matrix4.h:39
Matrix4 G3D::Matrix4::operator+ ( const Matrix4 other) const
inline
147  {
148  Matrix4 result;
149  for (int r = 0; r < 4; ++r) {
150  for (int c = 0; c < 4; ++c) {
151  result.elt[r][c] = elt[r][c] + other.elt[r][c];
152  }
153  }
154  return result;
155  }
Matrix4()
Definition: Matrix4.cpp:305
float elt[4][4]
Definition: Matrix4.h:39
bool G3D::Matrix4::operator< ( const Matrix4 ) const
private
bool G3D::Matrix4::operator<= ( const Matrix4 ) const
private
bool G3D::Matrix4::operator== ( const Matrix4 other) const
403  {
404 
405  // If the bit patterns are identical, they must be
406  // the same matrix. If not, they *might* still have
407  // equal elements due to floating point weirdness.
408  if (memcmp(this, &other, sizeof(Matrix4)) == 0) {
409  return true;
410  }
411 
412  for (int r = 0; r < 4; ++r) {
413  for (int c = 0; c < 4; ++c) {
414  if (elt[r][c] != other.elt[r][c]) {
415  return false;
416  }
417  }
418  }
419 
420  return true;
421 }
Matrix4()
Definition: Matrix4.cpp:305
float elt[4][4]
Definition: Matrix4.h:39
bool G3D::Matrix4::operator> ( const Matrix4 ) const
private
bool G3D::Matrix4::operator>= ( const Matrix4 ) const
private
float* G3D::Matrix4::operator[] ( int  r)
inline
125  {
126  debugAssert(r >= 0);
127  debugAssert(r < 4);
128  return (float*)&elt[r];
129  }
#define debugAssert(exp)
Definition: debugAssert.h:160
float elt[4][4]
Definition: Matrix4.h:39
const float* G3D::Matrix4::operator[] ( int  r) const
inline
131  {
132  debugAssert(r >= 0);
133  debugAssert(r < 4);
134  return (const float*)&elt[r];
135  }
#define debugAssert(exp)
Definition: debugAssert.h:160
float elt[4][4]
Definition: Matrix4.h:39
Matrix4 G3D::Matrix4::orthogonalProjection ( float  left,
float  right,
float  bottom,
float  top,
float  nearval,
float  farval,
float  upDirection = -1.0f 
)
static

Constructs an orthogonal projection matrix from the given parameters. Near and far are the NEGATIVE of the near and far plane Z values (to follow OpenGL conventions).

Parameters
upDirectionUse -1.0 for 2D Y increasing downwards (the G3D 8.x default convention), 1.0 for 2D Y increasing upwards (the G3D 7.x default and OpenGL convention)
163  {
164 
165  // Adapted from Mesa. Note that Microsoft (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc03_8qnj.asp)
166  // and Linux (http://www.xfree86.org/current/glOrtho.3.html) have different matrices shown in their documentation.
167 
168  float x, y, z;
169  float tx, ty, tz;
170 
171  x = 2.0f / (right-left);
172  y = 2.0f / (top-bottom);
173  z = -2.0f / (farval-nearval);
174  tx = -(right+left) / (right-left);
175  ty = -(top+bottom) / (top-bottom);
176  tz = -(farval+nearval) / (farval-nearval);
177 
178  y *= upDirection;
179  ty *= upDirection;
180 
181  return
182  Matrix4( x , 0.0f, 0.0f, tx,
183  0.0f, y , 0.0f, ty,
184  0.0f, 0.0f, z , tz,
185  0.0f, 0.0f, 0.0f, 1.0f);
186 }
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
bool left(const int *a, const int *b, const int *c)
Definition: RecastContour.cpp:487
Matrix4()
Definition: Matrix4.cpp:305
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Matrix4 G3D::Matrix4::orthogonalProjection ( const class Rect2D rect,
float  nearval,
float  farval,
float  upDirection = -1.0f 
)
static
Parameters
upDirectionUse -1.0 for 2D Y increasing downwards (the G3D 8.x default convention), 1.0 for 2D Y increasing upwards (the G3D 7.x default and OpenGL convention)
151  {
152  return Matrix4::orthogonalProjection(rect.x0(), rect.x1(), rect.y1(), rect.y0(), nearval, farval, upDirection);
153 }
static Matrix4 orthogonalProjection(float left, float right, float bottom, float top, float nearval, float farval, float upDirection=-1.0f)
Definition: Matrix4.cpp:156

+ Here is the call graph for this function:

Matrix4 G3D::Matrix4::perspectiveProjection ( double  left,
double  right,
double  bottom,
double  top,
double  nearval,
double  farval,
float  upDirection = -1.0f 
)
static
Parameters
upDirectionUse -1.0 for 2D Y increasing downwards (the G3D 8.x default convention), 1.0 for 2D Y increasing upwards (the G3D 7.x default and OpenGL convention)
Uses double precision because the operations involved in
projection involve divisions that can significantly impact
precision.     
196  {
197 
198  double x, y, a, b, c, d;
199 
200  x = (2.0*nearval) / (right-left);
201  y = (2.0*nearval) / (top-bottom);
202  a = (right+left) / (right-left);
203  b = (top+bottom) / (top-bottom);
204 
205  if (farval >= inf()) {
206  // Infinite view frustum
207  c = -1.0;
208  d = -2.0 * nearval;
209  } else {
210  c = -(farval+nearval) / (farval-nearval);
211  d = -(2.0*farval*nearval) / (farval-nearval);
212  }
213 
214  debugAssertM(abs(upDirection) == 1.0, "upDirection must be -1 or +1");
215  y *= upDirection;
216  b *= upDirection;
217 
218  return Matrix4(
219  (float)x, 0, (float)a, 0,
220  0, (float)y, (float)b, 0,
221  0, 0, (float)c, (float)d,
222  0, 0, -1, 0);
223 }
double abs(double fValue)
Definition: g3dmath.h:617
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
double inf()
Definition: g3dmath.cpp:40
G3D::int16 y
Definition: Vector2int16.h:38
bool left(const int *a, const int *b, const int *c)
Definition: RecastContour.cpp:487
Matrix4()
Definition: Matrix4.cpp:305
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

static Matrix4 G3D::Matrix4::pitchDegrees ( float  deg)
inlinestatic
270  {
272  }
static Matrix3 fromAxisAngle(const Vector3 &rkAxis, float fRadians)
Definition: Matrix3.cpp:1346
static const Vector3 & unitX()
Definition: Vector3.cpp:121
double toRadians(double deg)
Definition: g3dmath.h:798
Matrix4()
Definition: Matrix4.cpp:305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Matrix4 G3D::Matrix4::rollDegrees ( float  deg)
inlinestatic
274  {
276  }
static Matrix3 fromAxisAngle(const Vector3 &rkAxis, float fRadians)
Definition: Matrix3.cpp:1346
double toRadians(double deg)
Definition: g3dmath.h:798
static const Vector3 & unitZ()
Definition: Vector3.cpp:123
Matrix4()
Definition: Matrix4.cpp:305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const Vector4 & G3D::Matrix4::row ( int  r) const
328  {
329  return reinterpret_cast<const Vector4*>(elt[r])[0];
330 }
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the caller graph for this function:

static Matrix4 G3D::Matrix4::scale ( const Vector3 v)
inlinestatic

3D scale matrix

239  {
240  return Matrix4(v.x, 0, 0, 0,
241  0, v.y, 0, 0,
242  0, 0, v.z, 0,
243  0, 0, 0, 1);
244  }
Matrix4()
Definition: Matrix4.cpp:305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Matrix4 G3D::Matrix4::scale ( float  x,
float  y,
float  z 
)
inlinestatic

3D scale matrix

247  {
248  return scale(Vector3(x, y, z));
249  }
static Matrix4 scale(const Vector3 &v)
Definition: Matrix4.h:239
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

static Matrix4 G3D::Matrix4::scale ( float  s)
inlinestatic

3D scale matrix

252  {
253  return scale(s,s,s);
254  }
static Matrix4 scale(const Vector3 &v)
Definition: Matrix4.h:239

+ Here is the call graph for this function:

void G3D::Matrix4::serialize ( class BinaryOutput b) const

Serializes row-major

524  {
525  for (int r = 0; r < 4; ++r) {
526  for (int c = 0; c < 4; ++c) {
527  b.writeFloat32(elt[r][c]);
528  }
529  }
530 }
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the call graph for this function:

void G3D::Matrix4::setColumn ( int  c,
const Vector4 v 
)
321  {
322  for (int r = 0; r < 4; ++r) {
323  elt[r][c] = v[r];
324  }
325 }
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the caller graph for this function:

void G3D::Matrix4::setRow ( int  r,
const class Vector4 v 
)
314  {
315  for (int c = 0; c < 4; ++c) {
316  elt[r][c] = v[c];
317  }
318 }
float elt[4][4]
Definition: Matrix4.h:39
float G3D::Matrix4::subDeterminant ( int  excludeRow,
int  excludeCol 
) const
private

Computes the determinant of the 3x3 matrix that lacks excludeRow and excludeCol.

469  {
470  // Compute non-excluded row and column indices
471  int row[3];
472  int col[3];
473 
474  for (int i = 0; i < 3; ++i) {
475  row[i] = i;
476  col[i] = i;
477 
478  if (i >= excludeRow) {
479  ++row[i];
480  }
481  if (i >= excludeCol) {
482  ++col[i];
483  }
484  }
485 
486  // Compute the first row of cofactors
487  float cofactor00 =
488  elt[row[1]][col[1]] * elt[row[2]][col[2]] -
489  elt[row[1]][col[2]] * elt[row[2]][col[1]];
490 
491  float cofactor10 =
492  elt[row[1]][col[2]] * elt[row[2]][col[0]] -
493  elt[row[1]][col[0]] * elt[row[2]][col[2]];
494 
495  float cofactor20 =
496  elt[row[1]][col[0]] * elt[row[2]][col[1]] -
497  elt[row[1]][col[1]] * elt[row[2]][col[0]];
498 
499  // Product of the first row and the cofactors along the first row
500  return
501  elt[row[0]][col[0]] * cofactor00 +
502  elt[row[0]][col[1]] * cofactor10 +
503  elt[row[0]][col[2]] * cofactor20;
504 }
const Vector4 & row(int r) const
Definition: Matrix4.cpp:328
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Any G3D::Matrix4::toAny ( ) const
75  {
76  Any any(Any::ARRAY, "Matrix4");
77  any.resize(16);
78  for (int r = 0; r < 4; ++r) {
79  for (int c = 0; c < 4; ++c) {
80  any[r * 4 + c] = elt[r][c];
81  }
82  }
83 
84  return any;
85 }
bool any(float x)
Definition: g3dmath.h:424
Definition: Any.h:187
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the call graph for this function:

std::string G3D::Matrix4::toString ( ) const
541  {
542  return G3D::format("[%g, %g, %g, %g; %g, %g, %g, %g; %g, %g, %g, %g; %g, %g, %g, %g]",
543  elt[0][0], elt[0][1], elt[0][2], elt[0][3],
544  elt[1][0], elt[1][1], elt[1][2], elt[1][3],
545  elt[2][0], elt[2][1], elt[2][2], elt[2][3],
546  elt[3][0], elt[3][1], elt[3][2], elt[3][3]);
547 }
std::string __cdecl format(const char *fmt...) G3D_CHECK_PRINTF_ARGS
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the call graph for this function:

static Matrix4 G3D::Matrix4::translation ( const Vector3 v)
inlinestatic

3D translation matrix

257  {
258  return Matrix4(Matrix3::identity(), v);
259  }
Matrix4()
Definition: Matrix4.cpp:305
static const Matrix3 & identity()
Definition: Matrix3.cpp:70

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Matrix4 G3D::Matrix4::translation ( float  x,
float  y,
float  z 
)
inlinestatic
261  {
262  return Matrix4(Matrix3::identity(), Vector3(x, y, z));
263  }
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Matrix4()
Definition: Matrix4.cpp:305
G3D::int16 x
Definition: Vector2int16.h:37
static const Matrix3 & identity()
Definition: Matrix3.cpp:70

+ Here is the call graph for this function:

Matrix4 G3D::Matrix4::transpose ( ) const
386  {
387  Matrix4 result;
388  for (int r = 0; r < 4; ++r) {
389  for (int c = 0; c < 4; ++c) {
390  result.elt[c][r] = elt[r][c];
391  }
392  }
393 
394  return result;
395 }
Matrix4()
Definition: Matrix4.cpp:305
float elt[4][4]
Definition: Matrix4.h:39

+ Here is the caller graph for this function:

Matrix2 G3D::Matrix4::upper2x2 ( ) const
141  {
142  return Matrix2(elt[0][0], elt[0][1],
143  elt[1][0], elt[1][1]);
144 }
float elt[4][4]
Definition: Matrix4.h:39
Matrix3 G3D::Matrix4::upper3x3 ( ) const
134  {
135  return Matrix3(elt[0][0], elt[0][1], elt[0][2],
136  elt[1][0], elt[1][1], elt[1][2],
137  elt[2][0], elt[2][1], elt[2][2]);
138 }
float elt[4][4]
Definition: Matrix4.h:39
static Matrix4 G3D::Matrix4::yawDegrees ( float  deg)
inlinestatic

Create a rotation matrix that rotates deg degrees around the Y axis

266  {
268  }
static Matrix3 fromAxisAngle(const Vector3 &rkAxis, float fRadians)
Definition: Matrix3.cpp:1346
double toRadians(double deg)
Definition: g3dmath.h:798
static const Vector3 & unitY()
Definition: Vector3.cpp:122
Matrix4()
Definition: Matrix4.cpp:305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const Matrix4 & G3D::Matrix4::zero ( )
static
97  {
98  static Matrix4 m(
99  0, 0, 0, 0,
100  0, 0, 0, 0,
101  0, 0, 0, 0,
102  0, 0, 0, 0);
103  return m;
104 }
Matrix4()
Definition: Matrix4.cpp:305

Member Data Documentation

float G3D::Matrix4::elt[4][4]
private

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