Bullet Collision Detection & Physics Library
Macros
gim_linear_math.h File Reference
#include "gim_math.h"
#include "gim_geom_types.h"
Include dependency graph for gim_linear_math.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define VEC_ZERO_2(a)
 Zero out a 2D vector. More...
 
#define VEC_ZERO(a)
 Zero out a 3D vector. More...
 
#define VEC_ZERO_4(a)
 Zero out a 4D vector. More...
 
#define VEC_COPY_2(b, a)
 Vector copy. More...
 
#define VEC_COPY(b, a)
 Copy 3D vector. More...
 
#define VEC_COPY_4(b, a)
 Copy 4D vector. More...
 
#define VEC_SWAP(b, a)
 VECTOR SWAP. More...
 
#define VEC_DIFF_2(v21, v2, v1)
 Vector difference. More...
 
#define VEC_DIFF(v21, v2, v1)
 Vector difference. More...
 
#define VEC_DIFF_4(v21, v2, v1)
 Vector difference. More...
 
#define VEC_SUM_2(v21, v2, v1)
 Vector sum. More...
 
#define VEC_SUM(v21, v2, v1)
 Vector sum. More...
 
#define VEC_SUM_4(v21, v2, v1)
 Vector sum. More...
 
#define VEC_SCALE_2(c, a, b)
 scalar times vector More...
 
#define VEC_SCALE(c, a, b)
 scalar times vector More...
 
#define VEC_SCALE_4(c, a, b)
 scalar times vector More...
 
#define VEC_ACCUM_2(c, a, b)
 accumulate scaled vector More...
 
#define VEC_ACCUM(c, a, b)
 accumulate scaled vector More...
 
#define VEC_ACCUM_4(c, a, b)
 accumulate scaled vector More...
 
#define VEC_DOT_2(a, b)   ((a)[0]*(b)[0] + (a)[1]*(b)[1])
 Vector dot product. More...
 
#define VEC_DOT(a, b)   ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2])
 Vector dot product. More...
 
#define VEC_DOT_4(a, b)   ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] + (a)[3]*(b)[3])
 Vector dot product. More...
 
#define VEC_IMPACT_SQ(bsq, direction, position)
 vector impact parameter (squared) More...
 
#define VEC_IMPACT(bsq, direction, position)
 vector impact parameter More...
 
#define VEC_LENGTH_2(a, l)
 Vector length. More...
 
#define VEC_LENGTH(a, l)
 Vector length. More...
 
#define VEC_LENGTH_4(a, l)
 Vector length. More...
 
#define VEC_INV_LENGTH_2(a, l)
 Vector inv length. More...
 
#define VEC_INV_LENGTH(a, l)
 Vector inv length. More...
 
#define VEC_INV_LENGTH_4(a, l)
 Vector inv length. More...
 
#define VEC_DISTANCE(_len, _va, _vb)
 distance between two points More...
 
#define VEC_CONJUGATE_LENGTH(a, l)
 Vector length. More...
 
#define VEC_NORMALIZE(a)
 Vector length. More...
 
#define VEC_RENORMALIZE(a, newlen)
 Set Vector size. More...
 
#define VEC_CROSS(c, a, b)
 Vector cross. More...
 
#define VEC_PERPENDICULAR(vp, v, n)
 
#define VEC_PARALLEL(vp, v, n)
 
#define VEC_PROJECT(vp, v, n)
 
#define VEC_UNPROJECT(vp, v, n)
 
#define VEC_REFLECT(vr, v, n)
 
#define VEC_BLEND_AB(vr, sa, a, sb, b)
 
#define VEC_BLEND(vr, a, b, s)   VEC_BLEND_AB(vr,(1-s),a,s,b)
 
#define VEC_SET3(a, b, op, c)   a[0]=b[0] op c[0]; a[1]=b[1] op c[1]; a[2]=b[2] op c[2];
 
#define VEC_MAYOR_COORD(vec, maxc)
 Finds the bigger cartesian coordinate from a vector. More...
 
#define VEC_MINOR_AXES(vec, i0, i1)
 Finds the 2 smallest cartesian coordinates from a vector. More...
 
#define VEC_EQUAL(v1, v2)   (v1[0]==v2[0]&&v1[1]==v2[1]&&v1[2]==v2[2])
 
#define VEC_NEAR_EQUAL(v1, v2)   (GIM_NEAR_EQUAL(v1[0],v2[0])&&GIM_NEAR_EQUAL(v1[1],v2[1])&&GIM_NEAR_EQUAL(v1[2],v2[2]))
 
#define X_AXIS_CROSS_VEC(dst, src)
 Vector cross. More...
 
#define Y_AXIS_CROSS_VEC(dst, src)
 
#define Z_AXIS_CROSS_VEC(dst, src)
 
#define IDENTIFY_MATRIX_3X3(m)
 initialize matrix More...
 
#define IDENTIFY_MATRIX_4X4(m)
 
#define ZERO_MATRIX_4X4(m)
 
#define ROTX_CS(m, cosine, sine)
 
#define ROTY_CS(m, cosine, sine)
 
#define ROTZ_CS(m, cosine, sine)
 
#define COPY_MATRIX_2X2(b, a)
 
#define COPY_MATRIX_2X3(b, a)
 
#define COPY_MATRIX_3X3(b, a)
 
#define COPY_MATRIX_4X4(b, a)
 
#define TRANSPOSE_MATRIX_2X2(b, a)
 
#define TRANSPOSE_MATRIX_3X3(b, a)
 
#define TRANSPOSE_MATRIX_4X4(b, a)
 
#define SCALE_MATRIX_2X2(b, s, a)
 
#define SCALE_MATRIX_3X3(b, s, a)
 
#define SCALE_MATRIX_4X4(b, s, a)
 
#define SCALE_VEC_MATRIX_2X2(b, svec, a)
 
#define SCALE_VEC_MATRIX_3X3(b, svec, a)
 
#define SCALE_VEC_MATRIX_4X4(b, svec, a)
 
#define ACCUM_SCALE_MATRIX_2X2(b, s, a)
 
#define ACCUM_SCALE_MATRIX_3X3(b, s, a)
 
#define ACCUM_SCALE_MATRIX_4X4(b, s, a)
 
#define MATRIX_PRODUCT_2X2(c, a, b)
 
#define MATRIX_PRODUCT_3X3(c, a, b)
 
#define MATRIX_PRODUCT_4X4(c, a, b)
 
#define MAT_DOT_VEC_2X2(p, m, v)
 
#define MAT_DOT_VEC_3X3(p, m, v)
 
#define MAT_DOT_VEC_4X4(p, m, v)
 
#define MAT_DOT_VEC_3X4(p, m, v)
 
#define VEC_DOT_MAT_3X3(p, v, m)
 
#define MAT_DOT_VEC_2X3(p, m, v)
 The matrix is assumed to be an affine matrix, with last two entries representing a translation. More...
 
#define MAT_TRANSFORM_PLANE_4X4(pout, m, plane)
 Transform a plane. More...
 
#define INV_TRANSP_MAT_DOT_VEC_2X2(p, m, v)
 inverse transpose of matrix times vector More...
 
#define NORM_XFORM_2X2(p, m, v)
 transform normal vector by inverse transpose of matrix and then renormalize the vector More...
 
#define OUTER_PRODUCT_2X2(m, v, t)
 outer product of vector times vector transpose More...
 
#define OUTER_PRODUCT_3X3(m, v, t)
 outer product of vector times vector transpose More...
 
#define OUTER_PRODUCT_4X4(m, v, t)
 outer product of vector times vector transpose More...
 
#define ACCUM_OUTER_PRODUCT_2X2(m, v, t)
 outer product of vector times vector transpose More...
 
#define ACCUM_OUTER_PRODUCT_3X3(m, v, t)
 outer product of vector times vector transpose More...
 
#define ACCUM_OUTER_PRODUCT_4X4(m, v, t)
 outer product of vector times vector transpose More...
 
#define DETERMINANT_2X2(d, m)
 determinant of matrix More...
 
#define DETERMINANT_3X3(d, m)
 determinant of matrix More...
 
#define COFACTOR_4X4_IJ(fac, m, i, j)
 i,j,th cofactor of a 4x4 matrix More...
 
#define DETERMINANT_4X4(d, m)
 determinant of matrix More...
 
#define COFACTOR_2X2(a, m)
 cofactor of matrix More...
 
#define COFACTOR_3X3(a, m)
 cofactor of matrix More...
 
#define COFACTOR_4X4(a, m)
 cofactor of matrix More...
 
#define ADJOINT_2X2(a, m)
 adjoint of matrix More...
 
#define ADJOINT_3X3(a, m)
 adjoint of matrix More...
 
#define ADJOINT_4X4(a, m)
 adjoint of matrix More...
 
#define SCALE_ADJOINT_2X2(a, s, m)
 compute adjoint of matrix and scale More...
 
#define SCALE_ADJOINT_3X3(a, s, m)
 compute adjoint of matrix and scale More...
 
#define SCALE_ADJOINT_4X4(a, s, m)
 compute adjoint of matrix and scale More...
 
#define INVERT_2X2(b, det, a)
 inverse of matrix More...
 
#define INVERT_3X3(b, det, a)
 inverse of matrix More...
 
#define INVERT_4X4(b, det, a)
 inverse of matrix More...
 
#define MAT_GET_ROW(mat, vec3, rowindex)
 Get the triple(3) row of a transform matrix. More...
 
#define MAT_GET_ROW2(mat, vec2, rowindex)
 Get the tuple(2) row of a transform matrix. More...
 
#define MAT_GET_ROW4(mat, vec4, rowindex)
 Get the quad (4) row of a transform matrix. More...
 
#define MAT_GET_COL(mat, vec3, colindex)
 Get the triple(3) col of a transform matrix. More...
 
#define MAT_GET_COL2(mat, vec2, colindex)
 Get the tuple(2) col of a transform matrix. More...
 
#define MAT_GET_COL4(mat, vec4, colindex)
 Get the quad (4) col of a transform matrix. More...
 
#define MAT_GET_X(mat, vec3)
 Get the triple(3) col of a transform matrix. More...
 
#define MAT_GET_Y(mat, vec3)
 Get the triple(3) col of a transform matrix. More...
 
#define MAT_GET_Z(mat, vec3)
 Get the triple(3) col of a transform matrix. More...
 
#define MAT_SET_X(mat, vec3)
 Get the triple(3) col of a transform matrix. More...
 
#define MAT_SET_Y(mat, vec3)
 Get the triple(3) col of a transform matrix. More...
 
#define MAT_SET_Z(mat, vec3)
 Get the triple(3) col of a transform matrix. More...
 
#define MAT_GET_TRANSLATION(mat, vec3)
 Get the triple(3) col of a transform matrix. More...
 
#define MAT_SET_TRANSLATION(mat, vec3)
 Set the triple(3) col of a transform matrix. More...
 
#define MAT_DOT_ROW(mat, vec3, rowindex)   (vec3[0]*mat[rowindex][0] + vec3[1]*mat[rowindex][1] + vec3[2]*mat[rowindex][2])
 Returns the dot product between a vec3f and the row of a matrix. More...
 
#define MAT_DOT_ROW2(mat, vec2, rowindex)   (vec2[0]*mat[rowindex][0] + vec2[1]*mat[rowindex][1])
 Returns the dot product between a vec2f and the row of a matrix. More...
 
#define MAT_DOT_ROW4(mat, vec4, rowindex)   (vec4[0]*mat[rowindex][0] + vec4[1]*mat[rowindex][1] + vec4[2]*mat[rowindex][2] + vec4[3]*mat[rowindex][3])
 Returns the dot product between a vec4f and the row of a matrix. More...
 
#define MAT_DOT_COL(mat, vec3, colindex)   (vec3[0]*mat[0][colindex] + vec3[1]*mat[1][colindex] + vec3[2]*mat[2][colindex])
 Returns the dot product between a vec3f and the col of a matrix. More...
 
#define MAT_DOT_COL2(mat, vec2, colindex)   (vec2[0]*mat[0][colindex] + vec2[1]*mat[1][colindex])
 Returns the dot product between a vec2f and the col of a matrix. More...
 
#define MAT_DOT_COL4(mat, vec4, colindex)   (vec4[0]*mat[0][colindex] + vec4[1]*mat[1][colindex] + vec4[2]*mat[2][colindex] + vec4[3]*mat[3][colindex])
 Returns the dot product between a vec4f and the col of a matrix. More...
 
#define INV_MAT_DOT_VEC_3X3(p, m, v)
 

Detailed Description

Author
Francisco Leon Najera Type Independant Vector and matrix operations.

Definition in file gim_linear_math.h.

Macro Definition Documentation

#define ACCUM_OUTER_PRODUCT_2X2 (   m,
  v,
 
)
Value:
{ \
m[0][0] += v[0] * t[0]; \
m[0][1] += v[0] * t[1]; \
\
m[1][0] += v[1] * t[0]; \
m[1][1] += v[1] * t[1]; \
}\

outer product of vector times vector transpose

The outer product of vector v and vector transpose t yeilds dyadic matrix m.

Definition at line 1117 of file gim_linear_math.h.

#define ACCUM_OUTER_PRODUCT_3X3 (   m,
  v,
 
)
Value:
{ \
m[0][0] += v[0] * t[0]; \
m[0][1] += v[0] * t[1]; \
m[0][2] += v[0] * t[2]; \
\
m[1][0] += v[1] * t[0]; \
m[1][1] += v[1] * t[1]; \
m[1][2] += v[1] * t[2]; \
\
m[2][0] += v[2] * t[0]; \
m[2][1] += v[2] * t[1]; \
m[2][2] += v[2] * t[2]; \
}\

outer product of vector times vector transpose

The outer product of vector v and vector transpose t yeilds dyadic matrix m.

Definition at line 1132 of file gim_linear_math.h.

#define ACCUM_OUTER_PRODUCT_4X4 (   m,
  v,
 
)
Value:
{ \
m[0][0] += v[0] * t[0]; \
m[0][1] += v[0] * t[1]; \
m[0][2] += v[0] * t[2]; \
m[0][3] += v[0] * t[3]; \
\
m[1][0] += v[1] * t[0]; \
m[1][1] += v[1] * t[1]; \
m[1][2] += v[1] * t[2]; \
m[1][3] += v[1] * t[3]; \
\
m[2][0] += v[2] * t[0]; \
m[2][1] += v[2] * t[1]; \
m[2][2] += v[2] * t[2]; \
m[2][3] += v[2] * t[3]; \
\
m[3][0] += v[3] * t[0]; \
m[3][1] += v[3] * t[1]; \
m[3][2] += v[3] * t[2]; \
m[3][3] += v[3] * t[3]; \
}\

outer product of vector times vector transpose

The outer product of vector v and vector transpose t yeilds dyadic matrix m.

Definition at line 1153 of file gim_linear_math.h.

#define ACCUM_SCALE_MATRIX_2X2 (   b,
  s,
 
)
Value:
{ \
b[0][0] += (s) * a[0][0]; \
b[0][1] += (s) * a[0][1]; \
\
b[1][0] += (s) * a[1][0]; \
b[1][1] += (s) * a[1][1]; \
}\

multiply matrix by scalar

Definition at line 816 of file gim_linear_math.h.

#define ACCUM_SCALE_MATRIX_3X3 (   b,
  s,
 
)
Value:
{ \
b[0][0] += (s) * a[0][0]; \
b[0][1] += (s) * a[0][1]; \
b[0][2] += (s) * a[0][2]; \
\
b[1][0] += (s) * a[1][0]; \
b[1][1] += (s) * a[1][1]; \
b[1][2] += (s) * a[1][2]; \
\
b[2][0] += (s) * a[2][0]; \
b[2][1] += (s) * a[2][1]; \
b[2][2] += (s) * a[2][2]; \
}\

multiply matrix by scalar

Definition at line 827 of file gim_linear_math.h.

#define ACCUM_SCALE_MATRIX_4X4 (   b,
  s,
 
)
Value:
{ \
b[0][0] += (s) * a[0][0]; \
b[0][1] += (s) * a[0][1]; \
b[0][2] += (s) * a[0][2]; \
b[0][3] += (s) * a[0][3]; \
\
b[1][0] += (s) * a[1][0]; \
b[1][1] += (s) * a[1][1]; \
b[1][2] += (s) * a[1][2]; \
b[1][3] += (s) * a[1][3]; \
\
b[2][0] += (s) * a[2][0]; \
b[2][1] += (s) * a[2][1]; \
b[2][2] += (s) * a[2][2]; \
b[2][3] += (s) * a[2][3]; \
\
b[3][0] += (s) * a[3][0]; \
b[3][1] += (s) * a[3][1]; \
b[3][2] += (s) * a[3][2]; \
b[3][3] += (s) * a[3][3]; \
}\

multiply matrix by scalar

Definition at line 844 of file gim_linear_math.h.

#define ADJOINT_2X2 (   a,
 
)
Value:
{ \
a[0][0] = (m)[1][1]; \
a[1][0] = - (m)[1][0]; \
a[0][1] = - (m)[0][1]; \
a[1][1] = (m)[0][0]; \
}\

adjoint of matrix

Computes adjoint of matrix m, returning a (Note that adjoint is just the transpose of the cofactor matrix)

Definition at line 1295 of file gim_linear_math.h.

#define ADJOINT_3X3 (   a,
 
)
Value:
{ \
a[0][0] = m[1][1]*m[2][2] - m[1][2]*m[2][1]; \
a[1][0] = - (m[1][0]*m[2][2] - m[2][0]*m[1][2]); \
a[2][0] = m[1][0]*m[2][1] - m[1][1]*m[2][0]; \
a[0][1] = - (m[0][1]*m[2][2] - m[0][2]*m[2][1]); \
a[1][1] = m[0][0]*m[2][2] - m[0][2]*m[2][0]; \
a[2][1] = - (m[0][0]*m[2][1] - m[0][1]*m[2][0]); \
a[0][2] = m[0][1]*m[1][2] - m[0][2]*m[1][1]; \
a[1][2] = - (m[0][0]*m[1][2] - m[0][2]*m[1][0]); \
a[2][2] = m[0][0]*m[1][1] - m[0][1]*m[1][0]); \
}\

adjoint of matrix

Computes adjoint of matrix m, returning a (Note that adjoint is just the transpose of the cofactor matrix)

Definition at line 1309 of file gim_linear_math.h.

#define ADJOINT_4X4 (   a,
 
)
Value:
{ \
char _i_,_j_; \
\
for (_i_=0; _i_<4; _i_++) { \
for (_j_=0; _j_<4; _j_++) { \
COFACTOR_4X4_IJ (a[_j_][_i_], m, _i_, _j_); \
} \
} \
}\
#define COFACTOR_4X4_IJ(fac, m, i, j)
i,j,th cofactor of a 4x4 matrix

adjoint of matrix

Computes adjoint of matrix m, returning a (Note that adjoint is just the transpose of the cofactor matrix)

Definition at line 1328 of file gim_linear_math.h.

#define COFACTOR_2X2 (   a,
 
)
Value:
{ \
a[0][0] = (m)[1][1]; \
a[0][1] = - (m)[1][0]; \
a[1][0] = - (m)[0][1]; \
a[1][1] = (m)[0][0]; \
}\

cofactor of matrix

Computes cofactor of matrix m, returning a

Definition at line 1247 of file gim_linear_math.h.

#define COFACTOR_3X3 (   a,
 
)
Value:
{ \
a[0][0] = m[1][1]*m[2][2] - m[1][2]*m[2][1]; \
a[0][1] = - (m[1][0]*m[2][2] - m[2][0]*m[1][2]); \
a[0][2] = m[1][0]*m[2][1] - m[1][1]*m[2][0]; \
a[1][0] = - (m[0][1]*m[2][2] - m[0][2]*m[2][1]); \
a[1][1] = m[0][0]*m[2][2] - m[0][2]*m[2][0]; \
a[1][2] = - (m[0][0]*m[2][1] - m[0][1]*m[2][0]); \
a[2][0] = m[0][1]*m[1][2] - m[0][2]*m[1][1]; \
a[2][1] = - (m[0][0]*m[1][2] - m[0][2]*m[1][0]); \
a[2][2] = m[0][0]*m[1][1] - m[0][1]*m[1][0]); \
}\

cofactor of matrix

Computes cofactor of matrix m, returning a

Definition at line 1260 of file gim_linear_math.h.

#define COFACTOR_4X4 (   a,
 
)
Value:
{ \
int i,j; \
\
for (i=0; i<4; i++) { \
for (j=0; j<4; j++) { \
COFACTOR_4X4_IJ (a[i][j], m, i, j); \
} \
} \
}\
#define COFACTOR_4X4_IJ(fac, m, i, j)
i,j,th cofactor of a 4x4 matrix

cofactor of matrix

Computes cofactor of matrix m, returning a

Definition at line 1278 of file gim_linear_math.h.

#define COFACTOR_4X4_IJ (   fac,
  m,
  i,
 
)
Value:
{ \
GUINT __ii[4], __jj[4], __k; \
\
for (__k=0; __k<i; __k++) __ii[__k] = __k; \
for (__k=i; __k<3; __k++) __ii[__k] = __k+1; \
for (__k=0; __k<j; __k++) __jj[__k] = __k; \
for (__k=j; __k<3; __k++) __jj[__k] = __k+1; \
\
(fac) = m[__ii[0]][__jj[0]] * (m[__ii[1]][__jj[1]]*m[__ii[2]][__jj[2]] \
- m[__ii[1]][__jj[2]]*m[__ii[2]][__jj[1]]); \
(fac) -= m[__ii[0]][__jj[1]] * (m[__ii[1]][__jj[0]]*m[__ii[2]][__jj[2]] \
- m[__ii[1]][__jj[2]]*m[__ii[2]][__jj[0]]);\
(fac) += m[__ii[0]][__jj[2]] * (m[__ii[1]][__jj[0]]*m[__ii[2]][__jj[1]] \
- m[__ii[1]][__jj[1]]*m[__ii[2]][__jj[0]]);\
\
__k = i+j; \
if ( __k != (__k/2)*2) { \
(fac) = -(fac); \
} \
}\
#define GUINT
Definition: gim_math.h:42

i,j,th cofactor of a 4x4 matrix

Definition at line 1202 of file gim_linear_math.h.

#define COPY_MATRIX_2X2 (   b,
 
)
Value:
{ \
b[0][0] = a[0][0]; \
b[0][1] = a[0][1]; \
\
b[1][0] = a[1][0]; \
b[1][1] = a[1][1]; \
\
}\

matrix copy

Definition at line 590 of file gim_linear_math.h.

#define COPY_MATRIX_2X3 (   b,
 
)
Value:
{ \
b[0][0] = a[0][0]; \
b[0][1] = a[0][1]; \
b[0][2] = a[0][2]; \
\
b[1][0] = a[1][0]; \
b[1][1] = a[1][1]; \
b[1][2] = a[1][2]; \
}\

matrix copy

Definition at line 602 of file gim_linear_math.h.

#define COPY_MATRIX_3X3 (   b,
 
)
Value:
{ \
b[0][0] = a[0][0]; \
b[0][1] = a[0][1]; \
b[0][2] = a[0][2]; \
\
b[1][0] = a[1][0]; \
b[1][1] = a[1][1]; \
b[1][2] = a[1][2]; \
\
b[2][0] = a[2][0]; \
b[2][1] = a[2][1]; \
b[2][2] = a[2][2]; \
}\

matrix copy

Definition at line 615 of file gim_linear_math.h.

#define COPY_MATRIX_4X4 (   b,
 
)
Value:
{ \
b[0][0] = a[0][0]; \
b[0][1] = a[0][1]; \
b[0][2] = a[0][2]; \
b[0][3] = a[0][3]; \
\
b[1][0] = a[1][0]; \
b[1][1] = a[1][1]; \
b[1][2] = a[1][2]; \
b[1][3] = a[1][3]; \
\
b[2][0] = a[2][0]; \
b[2][1] = a[2][1]; \
b[2][2] = a[2][2]; \
b[2][3] = a[2][3]; \
\
b[3][0] = a[3][0]; \
b[3][1] = a[3][1]; \
b[3][2] = a[3][2]; \
b[3][3] = a[3][3]; \
}\

matrix copy

Definition at line 632 of file gim_linear_math.h.

#define DETERMINANT_2X2 (   d,
 
)
Value:
{ \
d = m[0][0] * m[1][1] - m[0][1] * m[1][0]; \
}\

determinant of matrix

Computes determinant of matrix m, returning d

Definition at line 1181 of file gim_linear_math.h.

#define DETERMINANT_3X3 (   d,
 
)
Value:
{ \
d = m[0][0] * (m[1][1]*m[2][2] - m[1][2] * m[2][1]); \
d -= m[0][1] * (m[1][0]*m[2][2] - m[1][2] * m[2][0]); \
d += m[0][2] * (m[1][0]*m[2][1] - m[1][1] * m[2][0]); \
}\

determinant of matrix

Computes determinant of matrix m, returning d

Definition at line 1191 of file gim_linear_math.h.

#define DETERMINANT_4X4 (   d,
 
)
Value:
{ \
GREAL cofac; \
COFACTOR_4X4_IJ (cofac, m, 0, 0); \
d = m[0][0] * cofac; \
COFACTOR_4X4_IJ (cofac, m, 0, 1); \
d += m[0][1] * cofac; \
COFACTOR_4X4_IJ (cofac, m, 0, 2); \
d += m[0][2] * cofac; \
COFACTOR_4X4_IJ (cofac, m, 0, 3); \
d += m[0][3] * cofac; \
}\
#define GREAL
Definition: gim_math.h:39
#define COFACTOR_4X4_IJ(fac, m, i, j)
i,j,th cofactor of a 4x4 matrix

determinant of matrix

Computes determinant of matrix m, returning d

Definition at line 1229 of file gim_linear_math.h.

#define IDENTIFY_MATRIX_3X3 (   m)
Value:
{ \
m[0][0] = 1.0; \
m[0][1] = 0.0; \
m[0][2] = 0.0; \
\
m[1][0] = 0.0; \
m[1][1] = 1.0; \
m[1][2] = 0.0; \
\
m[2][0] = 0.0; \
m[2][1] = 0.0; \
m[2][2] = 1.0; \
}\

initialize matrix

Definition at line 448 of file gim_linear_math.h.

#define IDENTIFY_MATRIX_4X4 (   m)
Value:
{ \
m[0][0] = 1.0; \
m[0][1] = 0.0; \
m[0][2] = 0.0; \
m[0][3] = 0.0; \
\
m[1][0] = 0.0; \
m[1][1] = 1.0; \
m[1][2] = 0.0; \
m[1][3] = 0.0; \
\
m[2][0] = 0.0; \
m[2][1] = 0.0; \
m[2][2] = 1.0; \
m[2][3] = 0.0; \
\
m[3][0] = 0.0; \
m[3][1] = 0.0; \
m[3][2] = 0.0; \
m[3][3] = 1.0; \
}\

initialize matrix

Definition at line 464 of file gim_linear_math.h.

#define INV_MAT_DOT_VEC_3X3 (   p,
  m,
 
)
Value:
{ \
p[0] = MAT_DOT_COL(m,v,0); \
p[1] = MAT_DOT_COL(m,v,1); \
p[2] = MAT_DOT_COL(m,v,2); \
}\
#define MAT_DOT_COL(mat, vec3, colindex)
Returns the dot product between a vec3f and the col of a matrix.

Transpose matrix times vector v is a vec3f and m is a mat4f

Definition at line 1564 of file gim_linear_math.h.

#define INV_TRANSP_MAT_DOT_VEC_2X2 (   p,
  m,
 
)
Value:
{ \
GREAL det; \
\
det = m[0][0]*m[1][1] - m[0][1]*m[1][0]; \
p[0] = m[1][1]*v[0] - m[1][0]*v[1]; \
p[1] = - m[0][1]*v[0] + m[0][0]*v[1]; \
\
/* if matrix not singular, and not orthonormal, then renormalize */ \
if ((det!=1.0f) && (det != 0.0f)) { \
det = 1.0f / det; \
p[0] *= det; \
p[1] *= det; \
} \
}\
#define GREAL
Definition: gim_math.h:39

inverse transpose of matrix times vector

This macro computes inverse transpose of matrix m, and multiplies vector v into it, to yeild vector p

DANGER !!! Do Not use this on normal vectors!!! It will leave normals the wrong length !!! See macro below for use on normals.

Definition at line 1003 of file gim_linear_math.h.

#define INVERT_2X2 (   b,
  det,
 
)
Value:
{ \
GREAL _tmp_; \
DETERMINANT_2X2 (det, a); \
_tmp_ = 1.0 / (det); \
SCALE_ADJOINT_2X2 (b, _tmp_, a); \
}\
#define SCALE_ADJOINT_2X2(a, s, m)
compute adjoint of matrix and scale
#define GREAL
Definition: gim_math.h:39
#define DETERMINANT_2X2(d, m)
determinant of matrix

inverse of matrix

Compute inverse of matrix a, returning determinant m and inverse b

Definition at line 1393 of file gim_linear_math.h.

#define INVERT_3X3 (   b,
  det,
 
)
Value:
{ \
GREAL _tmp_; \
DETERMINANT_3X3 (det, a); \
_tmp_ = 1.0 / (det); \
SCALE_ADJOINT_3X3 (b, _tmp_, a); \
}\
#define SCALE_ADJOINT_3X3(a, s, m)
compute adjoint of matrix and scale
#define GREAL
Definition: gim_math.h:39
#define DETERMINANT_3X3(d, m)
determinant of matrix

inverse of matrix

Compute inverse of matrix a, returning determinant m and inverse b

Definition at line 1407 of file gim_linear_math.h.

#define INVERT_4X4 (   b,
  det,
 
)
Value:
{ \
GREAL _tmp_; \
DETERMINANT_4X4 (det, a); \
_tmp_ = 1.0 / (det); \
SCALE_ADJOINT_4X4 (b, _tmp_, a); \
}\
#define GREAL
Definition: gim_math.h:39
#define SCALE_ADJOINT_4X4(a, s, m)
compute adjoint of matrix and scale
#define DETERMINANT_4X4(d, m)
determinant of matrix

inverse of matrix

Compute inverse of matrix a, returning determinant m and inverse b

Definition at line 1421 of file gim_linear_math.h.

#define MAT_DOT_COL (   mat,
  vec3,
  colindex 
)    (vec3[0]*mat[0][colindex] + vec3[1]*mat[1][colindex] + vec3[2]*mat[2][colindex])

Returns the dot product between a vec3f and the col of a matrix.

Definition at line 1552 of file gim_linear_math.h.

#define MAT_DOT_COL2 (   mat,
  vec2,
  colindex 
)    (vec2[0]*mat[0][colindex] + vec2[1]*mat[1][colindex])

Returns the dot product between a vec2f and the col of a matrix.

Definition at line 1555 of file gim_linear_math.h.

#define MAT_DOT_COL4 (   mat,
  vec4,
  colindex 
)    (vec4[0]*mat[0][colindex] + vec4[1]*mat[1][colindex] + vec4[2]*mat[2][colindex] + vec4[3]*mat[3][colindex])

Returns the dot product between a vec4f and the col of a matrix.

Definition at line 1558 of file gim_linear_math.h.

#define MAT_DOT_ROW (   mat,
  vec3,
  rowindex 
)    (vec3[0]*mat[rowindex][0] + vec3[1]*mat[rowindex][1] + vec3[2]*mat[rowindex][2])

Returns the dot product between a vec3f and the row of a matrix.

Definition at line 1542 of file gim_linear_math.h.

#define MAT_DOT_ROW2 (   mat,
  vec2,
  rowindex 
)    (vec2[0]*mat[rowindex][0] + vec2[1]*mat[rowindex][1])

Returns the dot product between a vec2f and the row of a matrix.

Definition at line 1545 of file gim_linear_math.h.

#define MAT_DOT_ROW4 (   mat,
  vec4,
  rowindex 
)    (vec4[0]*mat[rowindex][0] + vec4[1]*mat[rowindex][1] + vec4[2]*mat[rowindex][2] + vec4[3]*mat[rowindex][3])

Returns the dot product between a vec4f and the row of a matrix.

Definition at line 1548 of file gim_linear_math.h.

#define MAT_DOT_VEC_2X2 (   p,
  m,
 
)
Value:
{ \
p[0] = m[0][0]*v[0] + m[0][1]*v[1]; \
p[1] = m[1][0]*v[0] + m[1][1]*v[1]; \
}\

matrix times vector

Definition at line 924 of file gim_linear_math.h.

#define MAT_DOT_VEC_2X3 (   p,
  m,
 
)
Value:
{ \
p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]; \
p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]; \
}\

The matrix is assumed to be an affine matrix, with last two entries representing a translation.

affine matrix times vector

Definition at line 977 of file gim_linear_math.h.

#define MAT_DOT_VEC_3X3 (   p,
  m,
 
)
Value:
{ \
p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2]; \
p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2]; \
p[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2]; \
}\

matrix times vector

Definition at line 932 of file gim_linear_math.h.

#define MAT_DOT_VEC_3X4 (   p,
  m,
 
)
Value:
{ \
p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2] + m[0][3]; \
p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2] + m[1][3]; \
p[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2] + m[2][3]; \
}\

matrix times vector v is a vec3f and m is a mat4f
Last column is added as the position

Definition at line 956 of file gim_linear_math.h.

#define MAT_DOT_VEC_4X4 (   p,
  m,
 
)
Value:
{ \
p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2] + m[0][3]*v[3]; \
p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2] + m[1][3]*v[3]; \
p[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2] + m[2][3]*v[3]; \
p[3] = m[3][0]*v[0] + m[3][1]*v[1] + m[3][2]*v[2] + m[3][3]*v[3]; \
}\

matrix times vector v is a vec4f

Definition at line 943 of file gim_linear_math.h.

#define MAT_GET_COL (   mat,
  vec3,
  colindex 
)
Value:
{\
vec3[0] = mat[0][colindex];\
vec3[1] = mat[1][colindex];\
vec3[2] = mat[2][colindex]; \
}\

Get the triple(3) col of a transform matrix.

Definition at line 1455 of file gim_linear_math.h.

#define MAT_GET_COL2 (   mat,
  vec2,
  colindex 
)
Value:
{\
vec2[0] = mat[0][colindex];\
vec2[1] = mat[1][colindex];\
}\

Get the tuple(2) col of a transform matrix.

Definition at line 1463 of file gim_linear_math.h.

#define MAT_GET_COL4 (   mat,
  vec4,
  colindex 
)
Value:
{\
vec4[0] = mat[0][colindex];\
vec4[1] = mat[1][colindex];\
vec4[2] = mat[2][colindex];\
vec4[3] = mat[3][colindex];\
}\

Get the quad (4) col of a transform matrix.

Definition at line 1471 of file gim_linear_math.h.

#define MAT_GET_ROW (   mat,
  vec3,
  rowindex 
)
Value:
{\
vec3[0] = mat[rowindex][0];\
vec3[1] = mat[rowindex][1];\
vec3[2] = mat[rowindex][2]; \
}\

Get the triple(3) row of a transform matrix.

Definition at line 1430 of file gim_linear_math.h.

#define MAT_GET_ROW2 (   mat,
  vec2,
  rowindex 
)
Value:
{\
vec2[0] = mat[rowindex][0];\
vec2[1] = mat[rowindex][1];\
}\

Get the tuple(2) row of a transform matrix.

Definition at line 1438 of file gim_linear_math.h.

#define MAT_GET_ROW4 (   mat,
  vec4,
  rowindex 
)
Value:
{\
vec4[0] = mat[rowindex][0];\
vec4[1] = mat[rowindex][1];\
vec4[2] = mat[rowindex][2];\
vec4[3] = mat[rowindex][3];\
}\

Get the quad (4) row of a transform matrix.

Definition at line 1446 of file gim_linear_math.h.

#define MAT_GET_TRANSLATION (   mat,
  vec3 
)
Value:
{\
vec3[0] = mat[0][3];\
vec3[1] = mat[1][3];\
vec3[2] = mat[2][3]; \
}\

Get the triple(3) col of a transform matrix.

Definition at line 1524 of file gim_linear_math.h.

#define MAT_GET_X (   mat,
  vec3 
)
Value:
{\
MAT_GET_COL(mat,vec3,0);\
}\
#define MAT_GET_COL(mat, vec3, colindex)
Get the triple(3) col of a transform matrix.

Get the triple(3) col of a transform matrix.

Definition at line 1480 of file gim_linear_math.h.

#define MAT_GET_Y (   mat,
  vec3 
)
Value:
{\
MAT_GET_COL(mat,vec3,1);\
}\
#define MAT_GET_COL(mat, vec3, colindex)
Get the triple(3) col of a transform matrix.

Get the triple(3) col of a transform matrix.

Definition at line 1486 of file gim_linear_math.h.

#define MAT_GET_Z (   mat,
  vec3 
)
Value:
{\
MAT_GET_COL(mat,vec3,2);\
}\
#define MAT_GET_COL(mat, vec3, colindex)
Get the triple(3) col of a transform matrix.

Get the triple(3) col of a transform matrix.

Definition at line 1492 of file gim_linear_math.h.

#define MAT_SET_TRANSLATION (   mat,
  vec3 
)
Value:
{\
mat[0][3] = vec3[0];\
mat[1][3] = vec3[1];\
mat[2][3] = vec3[2]; \
}\

Set the triple(3) col of a transform matrix.

Definition at line 1532 of file gim_linear_math.h.

#define MAT_SET_X (   mat,
  vec3 
)
Value:
{\
mat[0][0] = vec3[0];\
mat[1][0] = vec3[1];\
mat[2][0] = vec3[2];\
}\

Get the triple(3) col of a transform matrix.

Definition at line 1499 of file gim_linear_math.h.

#define MAT_SET_Y (   mat,
  vec3 
)
Value:
{\
mat[0][1] = vec3[0];\
mat[1][1] = vec3[1];\
mat[2][1] = vec3[2];\
}\

Get the triple(3) col of a transform matrix.

Definition at line 1507 of file gim_linear_math.h.

#define MAT_SET_Z (   mat,
  vec3 
)
Value:
{\
mat[0][2] = vec3[0];\
mat[1][2] = vec3[1];\
mat[2][2] = vec3[2];\
}\

Get the triple(3) col of a transform matrix.

Definition at line 1515 of file gim_linear_math.h.

#define MAT_TRANSFORM_PLANE_4X4 (   pout,
  m,
  plane 
)
Value:
{ \
pout[0] = m[0][0]*plane[0] + m[0][1]*plane[1] + m[0][2]*plane[2];\
pout[1] = m[1][0]*plane[0] + m[1][1]*plane[1] + m[1][2]*plane[2];\
pout[2] = m[2][0]*plane[0] + m[2][1]*plane[1] + m[2][2]*plane[2];\
pout[3] = m[0][3]*pout[0] + m[1][3]*pout[1] + m[2][3]*pout[2] + plane[3];\
}\

Transform a plane.

Definition at line 984 of file gim_linear_math.h.

#define MATRIX_PRODUCT_2X2 (   c,
  a,
 
)
Value:
{ \
c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0]; \
c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1]; \
\
c[1][0] = a[1][0]*b[0][0]+a[1][1]*b[1][0]; \
c[1][1] = a[1][0]*b[0][1]+a[1][1]*b[1][1]; \
\
}\

matrix product

c[x][y] = a[x][0]*b[0][y]+a[x][1]*b[1][y]+a[x][2]*b[2][y]+a[x][3]*b[3][y];

Definition at line 869 of file gim_linear_math.h.

#define MATRIX_PRODUCT_3X3 (   c,
  a,
 
)
Value:
{ \
c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0]+a[0][2]*b[2][0]; \
c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1]+a[0][2]*b[2][1]; \
c[0][2] = a[0][0]*b[0][2]+a[0][1]*b[1][2]+a[0][2]*b[2][2]; \
\
c[1][0] = a[1][0]*b[0][0]+a[1][1]*b[1][0]+a[1][2]*b[2][0]; \
c[1][1] = a[1][0]*b[0][1]+a[1][1]*b[1][1]+a[1][2]*b[2][1]; \
c[1][2] = a[1][0]*b[0][2]+a[1][1]*b[1][2]+a[1][2]*b[2][2]; \
\
c[2][0] = a[2][0]*b[0][0]+a[2][1]*b[1][0]+a[2][2]*b[2][0]; \
c[2][1] = a[2][0]*b[0][1]+a[2][1]*b[1][1]+a[2][2]*b[2][1]; \
c[2][2] = a[2][0]*b[0][2]+a[2][1]*b[1][2]+a[2][2]*b[2][2]; \
}\

matrix product

c[x][y] = a[x][0]*b[0][y]+a[x][1]*b[1][y]+a[x][2]*b[2][y]+a[x][3]*b[3][y];

Definition at line 881 of file gim_linear_math.h.

#define MATRIX_PRODUCT_4X4 (   c,
  a,
 
)
Value:
{ \
c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0]+a[0][2]*b[2][0]+a[0][3]*b[3][0];\
c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1]+a[0][2]*b[2][1]+a[0][3]*b[3][1];\
c[0][2] = a[0][0]*b[0][2]+a[0][1]*b[1][2]+a[0][2]*b[2][2]+a[0][3]*b[3][2];\
c[0][3] = a[0][0]*b[0][3]+a[0][1]*b[1][3]+a[0][2]*b[2][3]+a[0][3]*b[3][3];\
\
c[1][0] = a[1][0]*b[0][0]+a[1][1]*b[1][0]+a[1][2]*b[2][0]+a[1][3]*b[3][0];\
c[1][1] = a[1][0]*b[0][1]+a[1][1]*b[1][1]+a[1][2]*b[2][1]+a[1][3]*b[3][1];\
c[1][2] = a[1][0]*b[0][2]+a[1][1]*b[1][2]+a[1][2]*b[2][2]+a[1][3]*b[3][2];\
c[1][3] = a[1][0]*b[0][3]+a[1][1]*b[1][3]+a[1][2]*b[2][3]+a[1][3]*b[3][3];\
\
c[2][0] = a[2][0]*b[0][0]+a[2][1]*b[1][0]+a[2][2]*b[2][0]+a[2][3]*b[3][0];\
c[2][1] = a[2][0]*b[0][1]+a[2][1]*b[1][1]+a[2][2]*b[2][1]+a[2][3]*b[3][1];\
c[2][2] = a[2][0]*b[0][2]+a[2][1]*b[1][2]+a[2][2]*b[2][2]+a[2][3]*b[3][2];\
c[2][3] = a[2][0]*b[0][3]+a[2][1]*b[1][3]+a[2][2]*b[2][3]+a[2][3]*b[3][3];\
\
c[3][0] = a[3][0]*b[0][0]+a[3][1]*b[1][0]+a[3][2]*b[2][0]+a[3][3]*b[3][0];\
c[3][1] = a[3][0]*b[0][1]+a[3][1]*b[1][1]+a[3][2]*b[2][1]+a[3][3]*b[3][1];\
c[3][2] = a[3][0]*b[0][2]+a[3][1]*b[1][2]+a[3][2]*b[2][2]+a[3][3]*b[3][2];\
c[3][3] = a[3][0]*b[0][3]+a[3][1]*b[1][3]+a[3][2]*b[2][3]+a[3][3]*b[3][3];\
}\

matrix product

c[x][y] = a[x][0]*b[0][y]+a[x][1]*b[1][y]+a[x][2]*b[2][y]+a[x][3]*b[3][y];

Definition at line 899 of file gim_linear_math.h.

#define NORM_XFORM_2X2 (   p,
  m,
 
)
Value:
{ \
GREAL len; \
\
/* do nothing if off-diagonals are zero and diagonals are \
* equal */ \
if ((m[0][1] != 0.0) || (m[1][0] != 0.0) || (m[0][0] != m[1][1])) { \
p[0] = m[1][1]*v[0] - m[1][0]*v[1]; \
p[1] = - m[0][1]*v[0] + m[0][0]*v[1]; \
\
len = p[0]*p[0] + p[1]*p[1]; \
GIM_INV_SQRT(len,len); \
p[0] *= len; \
p[1] *= len; \
} else { \
VEC_COPY_2 (p, v); \
} \
}\
#define GIM_INV_SQRT(va, isva)
Definition: gim_math.h:119
#define GREAL
Definition: gim_math.h:39
#define VEC_COPY_2(b, a)
Vector copy.

transform normal vector by inverse transpose of matrix and then renormalize the vector

This macro computes inverse transpose of matrix m, and multiplies vector v into it, to yeild vector p Vector p is then normalized.

Definition at line 1027 of file gim_linear_math.h.

#define OUTER_PRODUCT_2X2 (   m,
  v,
 
)
Value:
{ \
m[0][0] = v[0] * t[0]; \
m[0][1] = v[0] * t[1]; \
\
m[1][0] = v[1] * t[0]; \
m[1][1] = v[1] * t[1]; \
}\

outer product of vector times vector transpose

The outer product of vector v and vector transpose t yeilds dyadic matrix m.

Definition at line 1052 of file gim_linear_math.h.

#define OUTER_PRODUCT_3X3 (   m,
  v,
 
)
Value:
{ \
m[0][0] = v[0] * t[0]; \
m[0][1] = v[0] * t[1]; \
m[0][2] = v[0] * t[2]; \
\
m[1][0] = v[1] * t[0]; \
m[1][1] = v[1] * t[1]; \
m[1][2] = v[1] * t[2]; \
\
m[2][0] = v[2] * t[0]; \
m[2][1] = v[2] * t[1]; \
m[2][2] = v[2] * t[2]; \
}\

outer product of vector times vector transpose

The outer product of vector v and vector transpose t yeilds dyadic matrix m.

Definition at line 1067 of file gim_linear_math.h.

#define OUTER_PRODUCT_4X4 (   m,
  v,
 
)
Value:
{ \
m[0][0] = v[0] * t[0]; \
m[0][1] = v[0] * t[1]; \
m[0][2] = v[0] * t[2]; \
m[0][3] = v[0] * t[3]; \
\
m[1][0] = v[1] * t[0]; \
m[1][1] = v[1] * t[1]; \
m[1][2] = v[1] * t[2]; \
m[1][3] = v[1] * t[3]; \
\
m[2][0] = v[2] * t[0]; \
m[2][1] = v[2] * t[1]; \
m[2][2] = v[2] * t[2]; \
m[2][3] = v[2] * t[3]; \
\
m[3][0] = v[3] * t[0]; \
m[3][1] = v[3] * t[1]; \
m[3][2] = v[3] * t[2]; \
m[3][3] = v[3] * t[3]; \
}\

outer product of vector times vector transpose

The outer product of vector v and vector transpose t yeilds dyadic matrix m.

Definition at line 1088 of file gim_linear_math.h.

#define ROTX_CS (   m,
  cosine,
  sine 
)
Value:
{ \
/* rotation about the x-axis */ \
\
m[0][0] = 1.0; \
m[0][1] = 0.0; \
m[0][2] = 0.0; \
m[0][3] = 0.0; \
\
m[1][0] = 0.0; \
m[1][1] = (cosine); \
m[1][2] = (sine); \
m[1][3] = 0.0; \
\
m[2][0] = 0.0; \
m[2][1] = -(sine); \
m[2][2] = (cosine); \
m[2][3] = 0.0; \
\
m[3][0] = 0.0; \
m[3][1] = 0.0; \
m[3][2] = 0.0; \
m[3][3] = 1.0; \
}\

matrix rotation X

Definition at line 512 of file gim_linear_math.h.

#define ROTY_CS (   m,
  cosine,
  sine 
)
Value:
{ \
/* rotation about the y-axis */ \
\
m[0][0] = (cosine); \
m[0][1] = 0.0; \
m[0][2] = -(sine); \
m[0][3] = 0.0; \
\
m[1][0] = 0.0; \
m[1][1] = 1.0; \
m[1][2] = 0.0; \
m[1][3] = 0.0; \
\
m[2][0] = (sine); \
m[2][1] = 0.0; \
m[2][2] = (cosine); \
m[2][3] = 0.0; \
\
m[3][0] = 0.0; \
m[3][1] = 0.0; \
m[3][2] = 0.0; \
m[3][3] = 1.0; \
}\

matrix rotation Y

Definition at line 538 of file gim_linear_math.h.

#define ROTZ_CS (   m,
  cosine,
  sine 
)
Value:
{ \
/* rotation about the z-axis */ \
\
m[0][0] = (cosine); \
m[0][1] = (sine); \
m[0][2] = 0.0; \
m[0][3] = 0.0; \
\
m[1][0] = -(sine); \
m[1][1] = (cosine); \
m[1][2] = 0.0; \
m[1][3] = 0.0; \
\
m[2][0] = 0.0; \
m[2][1] = 0.0; \
m[2][2] = 1.0; \
m[2][3] = 0.0; \
\
m[3][0] = 0.0; \
m[3][1] = 0.0; \
m[3][2] = 0.0; \
m[3][3] = 1.0; \
}\

matrix rotation Z

Definition at line 564 of file gim_linear_math.h.

#define SCALE_ADJOINT_2X2 (   a,
  s,
 
)
Value:
{ \
a[0][0] = (s) * m[1][1]; \
a[1][0] = - (s) * m[1][0]; \
a[0][1] = - (s) * m[0][1]; \
a[1][1] = (s) * m[0][0]; \
}\

compute adjoint of matrix and scale

Computes adjoint of matrix m, scales it by s, returning a

Definition at line 1344 of file gim_linear_math.h.

#define SCALE_ADJOINT_3X3 (   a,
  s,
 
)
Value:
{ \
a[0][0] = (s) * (m[1][1] * m[2][2] - m[1][2] * m[2][1]); \
a[1][0] = (s) * (m[1][2] * m[2][0] - m[1][0] * m[2][2]); \
a[2][0] = (s) * (m[1][0] * m[2][1] - m[1][1] * m[2][0]); \
\
a[0][1] = (s) * (m[0][2] * m[2][1] - m[0][1] * m[2][2]); \
a[1][1] = (s) * (m[0][0] * m[2][2] - m[0][2] * m[2][0]); \
a[2][1] = (s) * (m[0][1] * m[2][0] - m[0][0] * m[2][1]); \
\
a[0][2] = (s) * (m[0][1] * m[1][2] - m[0][2] * m[1][1]); \
a[1][2] = (s) * (m[0][2] * m[1][0] - m[0][0] * m[1][2]); \
a[2][2] = (s) * (m[0][0] * m[1][1] - m[0][1] * m[1][0]); \
}\

compute adjoint of matrix and scale

Computes adjoint of matrix m, scales it by s, returning a

Definition at line 1357 of file gim_linear_math.h.

#define SCALE_ADJOINT_4X4 (   a,
  s,
 
)
Value:
{ \
char _i_,_j_; \
for (_i_=0; _i_<4; _i_++) { \
for (_j_=0; _j_<4; _j_++) { \
COFACTOR_4X4_IJ (a[_j_][_i_], m, _i_, _j_); \
a[_j_][_i_] *= s; \
} \
} \
}\
#define COFACTOR_4X4_IJ(fac, m, i, j)
i,j,th cofactor of a 4x4 matrix

compute adjoint of matrix and scale

Computes adjoint of matrix m, scales it by s, returning a

Definition at line 1377 of file gim_linear_math.h.

#define SCALE_MATRIX_2X2 (   b,
  s,
 
)
Value:
{ \
b[0][0] = (s) * a[0][0]; \
b[0][1] = (s) * a[0][1]; \
\
b[1][0] = (s) * a[1][0]; \
b[1][1] = (s) * a[1][1]; \
}\

multiply matrix by scalar

Definition at line 710 of file gim_linear_math.h.

#define SCALE_MATRIX_3X3 (   b,
  s,
 
)
Value:
{ \
b[0][0] = (s) * a[0][0]; \
b[0][1] = (s) * a[0][1]; \
b[0][2] = (s) * a[0][2]; \
\
b[1][0] = (s) * a[1][0]; \
b[1][1] = (s) * a[1][1]; \
b[1][2] = (s) * a[1][2]; \
\
b[2][0] = (s) * a[2][0]; \
b[2][1] = (s) * a[2][1]; \
b[2][2] = (s) * a[2][2]; \
}\

multiply matrix by scalar

Definition at line 721 of file gim_linear_math.h.

#define SCALE_MATRIX_4X4 (   b,
  s,
 
)
Value:
{ \
b[0][0] = (s) * a[0][0]; \
b[0][1] = (s) * a[0][1]; \
b[0][2] = (s) * a[0][2]; \
b[0][3] = (s) * a[0][3]; \
\
b[1][0] = (s) * a[1][0]; \
b[1][1] = (s) * a[1][1]; \
b[1][2] = (s) * a[1][2]; \
b[1][3] = (s) * a[1][3]; \
\
b[2][0] = (s) * a[2][0]; \
b[2][1] = (s) * a[2][1]; \
b[2][2] = (s) * a[2][2]; \
b[2][3] = (s) * a[2][3]; \
\
b[3][0] = s * a[3][0]; \
b[3][1] = s * a[3][1]; \
b[3][2] = s * a[3][2]; \
b[3][3] = s * a[3][3]; \
}\

multiply matrix by scalar

Definition at line 738 of file gim_linear_math.h.

#define SCALE_VEC_MATRIX_2X2 (   b,
  svec,
 
)
Value:
{ \
b[0][0] = svec[0] * a[0][0]; \
b[1][0] = svec[0] * a[1][0]; \
\
b[0][1] = svec[1] * a[0][1]; \
b[1][1] = svec[1] * a[1][1]; \
}\

multiply matrix by scalar

Definition at line 763 of file gim_linear_math.h.

#define SCALE_VEC_MATRIX_3X3 (   b,
  svec,
 
)
Value:
{ \
b[0][0] = svec[0] * a[0][0]; \
b[1][0] = svec[0] * a[1][0]; \
b[2][0] = svec[0] * a[2][0]; \
\
b[0][1] = svec[1] * a[0][1]; \
b[1][1] = svec[1] * a[1][1]; \
b[2][1] = svec[1] * a[2][1]; \
\
b[0][2] = svec[2] * a[0][2]; \
b[1][2] = svec[2] * a[1][2]; \
b[2][2] = svec[2] * a[2][2]; \
}\

multiply matrix by scalar. Each columns is scaled by each scalar vector component

Definition at line 774 of file gim_linear_math.h.

#define SCALE_VEC_MATRIX_4X4 (   b,
  svec,
 
)
Value:
{ \
b[0][0] = svec[0] * a[0][0]; \
b[1][0] = svec[0] * a[1][0]; \
b[2][0] = svec[0] * a[2][0]; \
b[3][0] = svec[0] * a[3][0]; \
\
b[0][1] = svec[1] * a[0][1]; \
b[1][1] = svec[1] * a[1][1]; \
b[2][1] = svec[1] * a[2][1]; \
b[3][1] = svec[1] * a[3][1]; \
\
b[0][2] = svec[2] * a[0][2]; \
b[1][2] = svec[2] * a[1][2]; \
b[2][2] = svec[2] * a[2][2]; \
b[3][2] = svec[2] * a[3][2]; \
\
b[0][3] = svec[3] * a[0][3]; \
b[1][3] = svec[3] * a[1][3]; \
b[2][3] = svec[3] * a[2][3]; \
b[3][3] = svec[3] * a[3][3]; \
}\

multiply matrix by scalar

Definition at line 791 of file gim_linear_math.h.

#define TRANSPOSE_MATRIX_2X2 (   b,
 
)
Value:
{ \
b[0][0] = a[0][0]; \
b[0][1] = a[1][0]; \
\
b[1][0] = a[0][1]; \
b[1][1] = a[1][1]; \
}\

matrix transpose

Definition at line 657 of file gim_linear_math.h.

#define TRANSPOSE_MATRIX_3X3 (   b,
 
)
Value:
{ \
b[0][0] = a[0][0]; \
b[0][1] = a[1][0]; \
b[0][2] = a[2][0]; \
\
b[1][0] = a[0][1]; \
b[1][1] = a[1][1]; \
b[1][2] = a[2][1]; \
\
b[2][0] = a[0][2]; \
b[2][1] = a[1][2]; \
b[2][2] = a[2][2]; \
}\

matrix transpose

Definition at line 668 of file gim_linear_math.h.

#define TRANSPOSE_MATRIX_4X4 (   b,
 
)
Value:
{ \
b[0][0] = a[0][0]; \
b[0][1] = a[1][0]; \
b[0][2] = a[2][0]; \
b[0][3] = a[3][0]; \
\
b[1][0] = a[0][1]; \
b[1][1] = a[1][1]; \
b[1][2] = a[2][1]; \
b[1][3] = a[3][1]; \
\
b[2][0] = a[0][2]; \
b[2][1] = a[1][2]; \
b[2][2] = a[2][2]; \
b[2][3] = a[3][2]; \
\
b[3][0] = a[0][3]; \
b[3][1] = a[1][3]; \
b[3][2] = a[2][3]; \
b[3][3] = a[3][3]; \
}\

matrix transpose

Definition at line 685 of file gim_linear_math.h.

#define VEC_ACCUM (   c,
  a,
 
)
Value:
{ \
(c)[0] += (a)*(b)[0]; \
(c)[1] += (a)*(b)[1]; \
(c)[2] += (a)*(b)[2]; \
}\

accumulate scaled vector

Definition at line 189 of file gim_linear_math.h.

#define VEC_ACCUM_2 (   c,
  a,
 
)
Value:
{ \
(c)[0] += (a)*(b)[0]; \
(c)[1] += (a)*(b)[1]; \
}\

accumulate scaled vector

Definition at line 181 of file gim_linear_math.h.

#define VEC_ACCUM_4 (   c,
  a,
 
)
Value:
{ \
(c)[0] += (a)*(b)[0]; \
(c)[1] += (a)*(b)[1]; \
(c)[2] += (a)*(b)[2]; \
(c)[3] += (a)*(b)[3]; \
}\

accumulate scaled vector

Definition at line 198 of file gim_linear_math.h.

#define VEC_BLEND (   vr,
  a,
  b,
 
)    VEC_BLEND_AB(vr,(1-s),a,s,b)

Vector blending Takes two vectors a, b, blends them together with s <=1

Definition at line 393 of file gim_linear_math.h.

#define VEC_BLEND_AB (   vr,
  sa,
  a,
  sb,
 
)
Value:
{ \
vr[0] = (sa) * (a)[0] + (sb) * (b)[0]; \
vr[1] = (sa) * (a)[1] + (sb) * (b)[1]; \
vr[2] = (sa) * (a)[2] + (sb) * (b)[2]; \
}\

Vector blending Takes two vectors a, b, blends them together with two scalars

Definition at line 384 of file gim_linear_math.h.

#define VEC_CONJUGATE_LENGTH (   a,
 
)
Value:
{\
GREAL _pp = 1.0 - a[0]*a[0] - a[1]*a[1] - a[2]*a[2];\
GIM_SQRT(_pp,l);\
}\
#define GIM_SQRT(va, sva)
Definition: gim_math.h:134
#define GREAL
Definition: gim_math.h:39

Vector length.

Definition at line 287 of file gim_linear_math.h.

#define VEC_COPY (   b,
 
)
Value:
{ \
(b)[0] = (a)[0]; \
(b)[1] = (a)[1]; \
(b)[2] = (a)[2]; \
}\

Copy 3D vector.

Definition at line 74 of file gim_linear_math.h.

#define VEC_COPY_2 (   b,
 
)
Value:
{ \
(b)[0] = (a)[0]; \
(b)[1] = (a)[1]; \
}\

Vector copy.

Definition at line 66 of file gim_linear_math.h.

#define VEC_COPY_4 (   b,
 
)
Value:
{ \
(b)[0] = (a)[0]; \
(b)[1] = (a)[1]; \
(b)[2] = (a)[2]; \
(b)[3] = (a)[3]; \
}\

Copy 4D vector.

Definition at line 83 of file gim_linear_math.h.

#define VEC_CROSS (   c,
  a,
 
)
Value:
{ \
c[0] = (a)[1] * (b)[2] - (a)[2] * (b)[1]; \
c[1] = (a)[2] * (b)[0] - (a)[0] * (b)[2]; \
c[2] = (a)[0] * (b)[1] - (a)[1] * (b)[0]; \
}\

Vector cross.

Definition at line 320 of file gim_linear_math.h.

#define VEC_DIFF (   v21,
  v2,
  v1 
)
Value:
{ \
(v21)[0] = (v2)[0] - (v1)[0]; \
(v21)[1] = (v2)[1] - (v1)[1]; \
(v21)[2] = (v2)[2] - (v1)[2]; \
}\

Vector difference.

Definition at line 108 of file gim_linear_math.h.

#define VEC_DIFF_2 (   v21,
  v2,
  v1 
)
Value:
{ \
(v21)[0] = (v2)[0] - (v1)[0]; \
(v21)[1] = (v2)[1] - (v1)[1]; \
}\

Vector difference.

Definition at line 100 of file gim_linear_math.h.

#define VEC_DIFF_4 (   v21,
  v2,
  v1 
)
Value:
{ \
(v21)[0] = (v2)[0] - (v1)[0]; \
(v21)[1] = (v2)[1] - (v1)[1]; \
(v21)[2] = (v2)[2] - (v1)[2]; \
(v21)[3] = (v2)[3] - (v1)[3]; \
}\

Vector difference.

Definition at line 117 of file gim_linear_math.h.

#define VEC_DISTANCE (   _len,
  _va,
  _vb 
)
Value:
{\
vec3f _tmp_; \
VEC_DIFF(_tmp_, _vb, _va); \
VEC_LENGTH(_tmp_,_len); \
}\
#define VEC_DIFF(v21, v2, v1)
Vector difference.
#define VEC_LENGTH(a, l)
Vector length.
GREAL vec3f[3]
Float vector 3D.

distance between two points

Definition at line 279 of file gim_linear_math.h.

#define VEC_DOT (   a,
 
)    ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2])

Vector dot product.

Definition at line 212 of file gim_linear_math.h.

#define VEC_DOT_2 (   a,
 
)    ((a)[0]*(b)[0] + (a)[1]*(b)[1])

Vector dot product.

Definition at line 208 of file gim_linear_math.h.

#define VEC_DOT_4 (   a,
 
)    ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] + (a)[3]*(b)[3])

Vector dot product.

Definition at line 215 of file gim_linear_math.h.

#define VEC_DOT_MAT_3X3 (   p,
  v,
 
)
Value:
{ \
p[0] = v[0]*m[0][0] + v[1]*m[1][0] + v[2]*m[2][0]; \
p[1] = v[0]*m[0][1] + v[1]*m[1][1] + v[2]*m[2][1]; \
p[2] = v[0]*m[0][2] + v[1]*m[1][2] + v[2]*m[2][2]; \
}\

vector transpose times matrix

p[j] = v[0]*m[0][j] + v[1]*m[1][j] + v[2]*m[2][j];

Definition at line 966 of file gim_linear_math.h.

#define VEC_EQUAL (   v1,
  v2 
)    (v1[0]==v2[0]&&v1[1]==v2[1]&&v1[2]==v2[2])

Definition at line 415 of file gim_linear_math.h.

#define VEC_IMPACT (   bsq,
  direction,
  position 
)
Value:
{\
VEC_IMPACT_SQ(bsq,direction,position); \
GIM_SQRT(bsq,bsq); \
}\
#define VEC_IMPACT_SQ(bsq, direction, position)
vector impact parameter (squared)
#define GIM_SQRT(va, sva)
Definition: gim_math.h:134

vector impact parameter

Definition at line 225 of file gim_linear_math.h.

#define VEC_IMPACT_SQ (   bsq,
  direction,
  position 
)
Value:
{\
GREAL _llel_ = VEC_DOT(direction, position);\
bsq = VEC_DOT(position, position) - _llel_*_llel_;\
}\
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT(a, b)
Vector dot product.

vector impact parameter (squared)

Definition at line 218 of file gim_linear_math.h.

#define VEC_INV_LENGTH (   a,
 
)
Value:
{\
GREAL _pp = VEC_DOT(a,a);\
GIM_INV_SQRT(_pp,l);\
}\
#define GIM_INV_SQRT(va, isva)
Definition: gim_math.h:119
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT(a, b)
Vector dot product.

Vector inv length.

Definition at line 262 of file gim_linear_math.h.

#define VEC_INV_LENGTH_2 (   a,
 
)
Value:
{\
GREAL _pp = VEC_DOT_2(a,a);\
GIM_INV_SQRT(_pp,l);\
}\
#define GIM_INV_SQRT(va, isva)
Definition: gim_math.h:119
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT_2(a, b)
Vector dot product.

Vector inv length.

Definition at line 254 of file gim_linear_math.h.

#define VEC_INV_LENGTH_4 (   a,
 
)
Value:
{\
GREAL _pp = VEC_DOT_4(a,a);\
GIM_INV_SQRT(_pp,l);\
}\
#define GIM_INV_SQRT(va, isva)
Definition: gim_math.h:119
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT_4(a, b)
Vector dot product.

Vector inv length.

Definition at line 270 of file gim_linear_math.h.

#define VEC_LENGTH (   a,
 
)
Value:
{\
GREAL _pp = VEC_DOT(a,a);\
GIM_SQRT(_pp,l);\
}\
#define GIM_SQRT(va, sva)
Definition: gim_math.h:134
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT(a, b)
Vector dot product.

Vector length.

Definition at line 239 of file gim_linear_math.h.

#define VEC_LENGTH_2 (   a,
 
)
Value:
{\
GREAL _pp = VEC_DOT_2(a,a);\
GIM_SQRT(_pp,l);\
}\
#define GIM_SQRT(va, sva)
Definition: gim_math.h:134
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT_2(a, b)
Vector dot product.

Vector length.

Definition at line 231 of file gim_linear_math.h.

#define VEC_LENGTH_4 (   a,
 
)
Value:
{\
GREAL _pp = VEC_DOT_4(a,a);\
GIM_SQRT(_pp,l);\
}\
#define GIM_SQRT(va, sva)
Definition: gim_math.h:134
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT_4(a, b)
Vector dot product.

Vector length.

Definition at line 247 of file gim_linear_math.h.

#define VEC_MAYOR_COORD (   vec,
  maxc 
)
Value:
{\
GREAL A[] = {fabs(vec[0]),fabs(vec[1]),fabs(vec[2])};\
maxc = A[0]>A[1]?(A[0]>A[2]?0:2):(A[1]>A[2]?1:2);\
}\
#define GREAL
Definition: gim_math.h:39
static float4 fabs(const float4 &a)

Finds the bigger cartesian coordinate from a vector.

Definition at line 398 of file gim_linear_math.h.

#define VEC_MINOR_AXES (   vec,
  i0,
  i1 
)
Value:
{\
i0 = (i0+1)%3;\
i1 = (i0+1)%3;\
}\
#define VEC_MAYOR_COORD(vec, maxc)
Finds the bigger cartesian coordinate from a vector.

Finds the 2 smallest cartesian coordinates from a vector.

Definition at line 405 of file gim_linear_math.h.

#define VEC_NEAR_EQUAL (   v1,
  v2 
)    (GIM_NEAR_EQUAL(v1[0],v2[0])&&GIM_NEAR_EQUAL(v1[1],v2[1])&&GIM_NEAR_EQUAL(v1[2],v2[2]))

Definition at line 417 of file gim_linear_math.h.

#define VEC_NORMALIZE (   a)
Value:
{ \
GREAL len;\
VEC_INV_LENGTH(a,len); \
if(len<G_REAL_INFINITY)\
{\
a[0] *= len; \
a[1] *= len; \
a[2] *= len; \
} \
}\
#define GREAL
Definition: gim_math.h:39
#define G_REAL_INFINITY
Definition: gim_math.h:58
#define VEC_INV_LENGTH(a, l)
Vector inv length.

Vector length.

Definition at line 295 of file gim_linear_math.h.

#define VEC_PARALLEL (   vp,
  v,
 
)
Value:
{ \
GREAL dot = VEC_DOT(v, n); \
vp[0] = (dot) * (n)[0]; \
vp[1] = (dot) * (n)[1]; \
vp[2] = (dot) * (n)[2]; \
}\
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT(a, b)
Vector dot product.
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
Definition: btQuaternion.h:827

Vector parallel – assumes that n is of unit length

Definition at line 340 of file gim_linear_math.h.

#define VEC_PERPENDICULAR (   vp,
  v,
 
)
Value:
{ \
GREAL dot = VEC_DOT(v, n); \
vp[0] = (v)[0] - dot*(n)[0]; \
vp[1] = (v)[1] - dot*(n)[1]; \
vp[2] = (v)[2] - dot*(n)[2]; \
}\
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT(a, b)
Vector dot product.
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
Definition: btQuaternion.h:827

Vector perp – assumes that n is of unit length accepts vector v, subtracts out any component parallel to n

Definition at line 330 of file gim_linear_math.h.

#define VEC_PROJECT (   vp,
  v,
 
)
Value:
{ \
GREAL scalar = VEC_DOT(v, n); \
scalar/= VEC_DOT(n, n); \
vp[0] = (scalar) * (n)[0]; \
vp[1] = (scalar) * (n)[1]; \
vp[2] = (scalar) * (n)[2]; \
}\
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT(a, b)
Vector dot product.

Same as Vector parallel – n can have any length accepts vector v, subtracts out any component perpendicular to n

Definition at line 350 of file gim_linear_math.h.

#define VEC_REFLECT (   vr,
  v,
 
)
Value:
{ \
GREAL dot = VEC_DOT(v, n); \
vr[0] = (v)[0] - 2.0 * (dot) * (n)[0]; \
vr[1] = (v)[1] - 2.0 * (dot) * (n)[1]; \
vr[2] = (v)[2] - 2.0 * (dot) * (n)[2]; \
}\
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT(a, b)
Vector dot product.
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
Definition: btQuaternion.h:827

Vector reflection – assumes n is of unit length Takes vector v, reflects it against reflector n, and returns vr

Definition at line 373 of file gim_linear_math.h.

#define VEC_RENORMALIZE (   a,
  newlen 
)
Value:
{ \
GREAL len;\
VEC_INV_LENGTH(a,len); \
if(len<G_REAL_INFINITY)\
{\
len *= newlen;\
a[0] *= len; \
a[1] *= len; \
a[2] *= len; \
} \
}\
#define GREAL
Definition: gim_math.h:39
#define G_REAL_INFINITY
Definition: gim_math.h:58
#define VEC_INV_LENGTH(a, l)
Vector inv length.

Set Vector size.

Definition at line 307 of file gim_linear_math.h.

#define VEC_SCALE (   c,
  a,
 
)
Value:
{ \
(c)[0] = (a)*(b)[0]; \
(c)[1] = (a)*(b)[1]; \
(c)[2] = (a)*(b)[2]; \
}\

scalar times vector

Definition at line 162 of file gim_linear_math.h.

#define VEC_SCALE_2 (   c,
  a,
 
)
Value:
{ \
(c)[0] = (a)*(b)[0]; \
(c)[1] = (a)*(b)[1]; \
}\

scalar times vector

Definition at line 154 of file gim_linear_math.h.

#define VEC_SCALE_4 (   c,
  a,
 
)
Value:
{ \
(c)[0] = (a)*(b)[0]; \
(c)[1] = (a)*(b)[1]; \
(c)[2] = (a)*(b)[2]; \
(c)[3] = (a)*(b)[3]; \
}\

scalar times vector

Definition at line 171 of file gim_linear_math.h.

#define VEC_SET3 (   a,
  b,
  op,
 
)    a[0]=b[0] op c[0]; a[1]=b[1] op c[1]; a[2]=b[2] op c[2];

Definition at line 395 of file gim_linear_math.h.

#define VEC_SUM (   v21,
  v2,
  v1 
)
Value:
{ \
(v21)[0] = (v2)[0] + (v1)[0]; \
(v21)[1] = (v2)[1] + (v1)[1]; \
(v21)[2] = (v2)[2] + (v1)[2]; \
}\

Vector sum.

Definition at line 135 of file gim_linear_math.h.

#define VEC_SUM_2 (   v21,
  v2,
  v1 
)
Value:
{ \
(v21)[0] = (v2)[0] + (v1)[0]; \
(v21)[1] = (v2)[1] + (v1)[1]; \
}\

Vector sum.

Definition at line 127 of file gim_linear_math.h.

#define VEC_SUM_4 (   v21,
  v2,
  v1 
)
Value:
{ \
(v21)[0] = (v2)[0] + (v1)[0]; \
(v21)[1] = (v2)[1] + (v1)[1]; \
(v21)[2] = (v2)[2] + (v1)[2]; \
(v21)[3] = (v2)[3] + (v1)[3]; \
}\

Vector sum.

Definition at line 144 of file gim_linear_math.h.

#define VEC_SWAP (   b,
 
)
Value:
{ \
GIM_SWAP_NUMBERS((b)[0],(a)[0]);\
GIM_SWAP_NUMBERS((b)[1],(a)[1]);\
GIM_SWAP_NUMBERS((b)[2],(a)[2]);\
}\
#define GIM_SWAP_NUMBERS(a, b)
Swap numbers.
Definition: gim_math.h:113

VECTOR SWAP.

Definition at line 92 of file gim_linear_math.h.

#define VEC_UNPROJECT (   vp,
  v,
 
)
Value:
{ \
GREAL scalar = VEC_DOT(v, n); \
scalar = VEC_DOT(n, n)/scalar; \
vp[0] = (scalar) * (n)[0]; \
vp[1] = (scalar) * (n)[1]; \
vp[2] = (scalar) * (n)[2]; \
}\
#define GREAL
Definition: gim_math.h:39
#define VEC_DOT(a, b)
Vector dot product.

accepts vector v

Definition at line 361 of file gim_linear_math.h.

#define VEC_ZERO (   a)
Value:
{ \
(a)[0] = (a)[1] = (a)[2] = 0.0f; \
}\

Zero out a 3D vector.

Definition at line 52 of file gim_linear_math.h.

#define VEC_ZERO_2 (   a)
Value:
{ \
(a)[0] = (a)[1] = 0.0f; \
}\

Zero out a 2D vector.

Definition at line 45 of file gim_linear_math.h.

#define VEC_ZERO_4 (   a)
Value:
{ \
(a)[0] = (a)[1] = (a)[2] = (a)[3] = 0.0f; \
}\

Zero out a 4D vector.

Definition at line 59 of file gim_linear_math.h.

#define X_AXIS_CROSS_VEC (   dst,
  src 
)
Value:
{ \
dst[0] = 0.0f; \
dst[1] = -src[2]; \
dst[2] = src[1]; \
}\

Vector cross.

Definition at line 421 of file gim_linear_math.h.

#define Y_AXIS_CROSS_VEC (   dst,
  src 
)
Value:
{ \
dst[0] = src[2]; \
dst[1] = 0.0f; \
dst[2] = -src[0]; \
}\

Definition at line 428 of file gim_linear_math.h.

#define Z_AXIS_CROSS_VEC (   dst,
  src 
)
Value:
{ \
dst[0] = -src[1]; \
dst[1] = src[0]; \
dst[2] = 0.0f; \
}\

Definition at line 435 of file gim_linear_math.h.

#define ZERO_MATRIX_4X4 (   m)
Value:
{ \
m[0][0] = 0.0; \
m[0][1] = 0.0; \
m[0][2] = 0.0; \
m[0][3] = 0.0; \
\
m[1][0] = 0.0; \
m[1][1] = 0.0; \
m[1][2] = 0.0; \
m[1][3] = 0.0; \
\
m[2][0] = 0.0; \
m[2][1] = 0.0; \
m[2][2] = 0.0; \
m[2][3] = 0.0; \
\
m[3][0] = 0.0; \
m[3][1] = 0.0; \
m[3][2] = 0.0; \
m[3][3] = 0.0; \
}\

initialize matrix

Definition at line 488 of file gim_linear_math.h.