QuakeForge  0.7.2.210-815cf
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
4x4 matrix functions

Macros

#define Mat3toMat4(a, b)
 
#define Mat4Add(a, b, c)
 
#define Mat4Blend(m1, m2, b, m)
 
#define Mat4CompMult(a, b, c)
 
#define Mat4Copy(a, b)
 
#define Mat4Expand(a)
 
#define Mat4Identity(a)
 
#define Mat4MultAdd(a, s, b, c)
 
#define Mat4Scale(a, b, c)
 
#define Mat4Subtract(a, b, c)
 
#define Mat4Trace(a)   ((a)[0] + (a)[5] + (a)[10] + (a)[15])
 
#define Mat4Zero(a)   memset ((a), 0, 16 * sizeof (a)[0])
 

Functions

void Mat4as3MultVec (const mat4_t a, const vec3_t b, vec3_t c)
 
int Mat4Decompose (const mat4_t mat, quat_t rot, vec3_t shear, vec3_t scale, vec3_t trans)
 Decompose a 4x4 column major matrix into its component transformations. More...
 
void Mat4Init (const quat_t rot, const vec3_t scale, const vec3_t trans, mat4_t mat)
 
int Mat4Inverse (const mat4_t a, mat4_t b)
 
void Mat4Mult (const mat4_t a, const mat4_t b, mat4_t c)
 
void Mat4MultVec (const mat4_t a, const vec3_t b, vec3_t c)
 
void Mat4Transpose (const mat4_t a, mat4_t b)
 

Detailed Description

Macro Definition Documentation

#define Mat3toMat4 (   a,
 
)
Value:
do { \
VectorCopy ((a) + 0, (b) + 0); (b)[3] = 0; \
VectorCopy ((a) + 3, (b) + 4); (b)[7] = 0; \
VectorCopy ((a) + 6, (b) + 8); (b)[11] = 0; \
QuatZero ((b) + 12); \
} while (0)
#define VectorCopy(a, b)
Definition: vector.h:59
#define QuatZero(a)
Definition: quaternion.h:145
#define Mat4Add (   a,
  b,
 
)
Value:
do { \
QuatAdd ((a) + 0, (b) + 0, (c) + 0); \
QuatAdd ((a) + 4, (b) + 4, (c) + 4); \
QuatAdd ((a) + 8, (b) + 8, (c) + 8); \
QuatAdd ((a) + 12, (b) + 12, (c) + 12); \
} while (0)
#define QuatAdd(a, b, c)
Definition: quaternion.h:66
#define Mat4Blend (   m1,
  m2,
  b,
 
)
Value:
do { \
QuatBlend ((m1) + 0, (m2) + 0, (b), (m) + 0); \
QuatBlend ((m1) + 4, (m2) + 4, (b), (m) + 4); \
QuatBlend ((m1) + 8, (m2) + 8, (b), (m) + 8); \
QuatBlend ((m1) + 12, (m2) + 12, (b), (m) + 12); \
} while (0)
#define QuatBlend(q1, q2, b, q)
Definition: quaternion.h:154
#define Mat4CompMult (   a,
  b,
 
)
Value:
do { \
QuatCompMult ((a) + 0, (b) + 0, (c) + 0); \
QuatCompMult ((a) + 4, (b) + 4, (c) + 4); \
QuatCompMult ((a) + 8, (b) + 8, (c) + 8); \
QuatCompMult ((a) + 12, (b) + 12, (c) + 12); \
} while (0)
#define QuatCompMult(a, b, c)
Definition: quaternion.h:104
#define Mat4Copy (   a,
 
)
Value:
do { \
QuatCopy ((a) + 0, (b) + 0); \
QuatCopy ((a) + 4, (b) + 4); \
QuatCopy ((a) + 8, (b) + 8); \
QuatCopy ((a) + 12, (b) + 12); \
} while (0)
#define QuatCopy(a, b)
Definition: quaternion.h:73
#define Mat4Expand (   a)
Value:
QuatExpand ((a) + 0), \
QuatExpand ((a) + 4), \
QuatExpand ((a) + 8), \
QuatExpand ((a) + 12)
#define QuatExpand(q)
Definition: quaternion.h:163
#define Mat4Identity (   a)
Value:
do { \
Mat4Zero (a); \
(a)[15] = (a)[10] = (a)[5] = (a)[0] = 1; \
} while (0)
#define Mat4Zero(a)
Definition: matrix4.h:76
#define Mat4MultAdd (   a,
  s,
  b,
 
)
Value:
do { \
QuatMultAdd ((a) + 0, s, (b) + 0, (c) + 0); \
QuatMultAdd ((a) + 4, s, (b) + 4, (c) + 4); \
QuatMultAdd ((a) + 8, s, (b) + 8, (c) + 8); \
QuatMultAdd ((a) + 12, s, (b) + 12, (c) + 12); \
} while (0)
#define QuatMultAdd(a, s, b, c)
Definition: quaternion.h:80
#define Mat4Scale (   a,
  b,
 
)
Value:
do { \
QuatScale ((a) + 0, (b), (c) + 0); \
QuatScale ((a) + 4, (b), (c) + 4); \
QuatScale ((a) + 8, (b), (c) + 8); \
QuatScale ((a) + 12, (b), (c) + 12); \
} while (0)
#define QuatScale(a, b, c)
Definition: quaternion.h:96
#define Mat4Subtract (   a,
  b,
 
)
Value:
do { \
QuatSubtract ((a) + 0, (b) + 0, (c) + 0); \
QuatSubtract ((a) + 4, (b) + 4, (c) + 4); \
QuatSubtract ((a) + 8, (b) + 8, (c) + 8); \
QuatSubtract ((a) + 12, (b) + 12, (c) + 12); \
} while (0)
#define QuatSubtract(a, b, c)
Definition: quaternion.h:45
#define Mat4Trace (   a)    ((a)[0] + (a)[5] + (a)[10] + (a)[15])
#define Mat4Zero (   a)    memset ((a), 0, 16 * sizeof (a)[0])

Function Documentation

void Mat4as3MultVec ( const mat4_t  a,
const vec3_t  b,
vec3_t  c 
)
int Mat4Decompose ( const mat4_t  mat,
quat_t  rot,
vec3_t  shear,
vec3_t  scale,
vec3_t  trans 
)

Decompose a 4x4 column major matrix into its component transformations.

This gives the matrix's rotation as a quaternion, shear (XY, XZ, YZ), scale, and translation. Using the following sequence will give the same result as multiplying v by mat.

QuatMultVec (rot, v, v); VectorShear (shear, v, v); VectorCompMult (scale, v, v); VectorAdd (trans, v, v);

void Mat4Init ( const quat_t  rot,
const vec3_t  scale,
const vec3_t  trans,
mat4_t  mat 
)
int Mat4Inverse ( const mat4_t  a,
mat4_t  b 
)
void Mat4Mult ( const mat4_t  a,
const mat4_t  b,
mat4_t  c 
)
void Mat4MultVec ( const mat4_t  a,
const vec3_t  b,
vec3_t  c 
)
void Mat4Transpose ( const mat4_t  a,
mat4_t  b 
)