Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

matrix33.c File Reference

#include <assert.h>
#include <math.h>
#include "vec3d.h"
#include "xform3d.h"
#include "matrix33.h"

Go to the source code of this file.

Functions

void Matrix33_MakeCrossProductMatrix33 (const geVec3d *v, Matrix33 *m)
void Matrix33_ExtractFromXForm3d (const geXForm3d *xform, Matrix33 *m)
void Matrix33_MultiplyVec3d (const Matrix33 *m, const geVec3d *v, geVec3d *res)
void Matrix33_Multiply (const Matrix33 *m1, const Matrix33 *m2, Matrix33 *res)
void Matrix33_GetTranspose (const Matrix33 *m, Matrix33 *t)
void Matrix33_Copy (const Matrix33 *m, Matrix33 *c)
void Matrix33_SetIdentity (Matrix33 *m)
void Matrix33_Add (const Matrix33 *m1, const Matrix33 *m2, Matrix33 *res)
void Matrix33_Subtract (const Matrix33 *m1, const Matrix33 *m2, Matrix33 *res)
void Matrix33_MultiplyScalar (geFloat s, const Matrix33 *m, Matrix33 *res)
void Matrix33_GetInverse (const Matrix33 *m, Matrix33 *inv)


Function Documentation

void Matrix33_Add const Matrix33 m1,
const Matrix33 m2,
Matrix33 res
 

Definition at line 121 of file matrix33.c.

References NULL, and Matrix33::x.

Referenced by gePhysicsSystem_EnforceConstraints().

00122 {
00123         int i, j;
00124 
00125         assert(m1 != NULL);
00126         assert(m2 != NULL);
00127         assert(res != NULL);
00128 
00129         for (i = 0; i < 3; i++)
00130                 for (j = 0; j < 3; j++)
00131                         res->x[i][j] = m1->x[i][j] + m2->x[i][j];
00132 }

void Matrix33_Copy const Matrix33 m,
Matrix33 c
 

Definition at line 94 of file matrix33.c.

References NULL, and Matrix33::x.

Referenced by gePhysicsObject_GetInertiaTensor(), gePhysicsObject_GetInertiaTensorInverse(), and Matrix33_GetInverse().

00095 {
00096         int i, j;
00097 
00098         assert(m != NULL);
00099         assert(c != NULL);
00100 
00101         for (i = 0; i < 3; i++)
00102                 for (j = 0; j < 3; j++)
00103                         c->x[i][j] = m->x[i][j];
00104 }

void Matrix33_ExtractFromXForm3d const geXForm3d xform,
Matrix33 m
 

Definition at line 41 of file matrix33.c.

References geXForm3d::AX, geXForm3d::AY, geXForm3d::AZ, geXForm3d::BX, geXForm3d::BY, geXForm3d::BZ, geXForm3d::CX, geXForm3d::CY, geXForm3d::CZ, NULL, and Matrix33::x.

Referenced by gePhysicsObject_ApplyGlobalFrameImpulse(), gePhysicsObject_GetInertiaTensorInPhysicsSpace(), gePhysicsObject_GetInertiaTensorInverseInPhysicsSpace(), gePhysicsObject_Integrate(), gePhysicsSystem_EnforceConstraints(), and PhysicsObject_Control().

00042 {
00043         assert(xform != NULL);
00044         assert(m != NULL);
00045 
00046         m->x[0][0] = xform->AX; m->x[0][1] = xform->AY; m->x[0][2] = xform->AZ;
00047         m->x[1][0] = xform->BX; m->x[1][1] = xform->BY; m->x[1][2] = xform->BZ;
00048         m->x[2][0] = xform->CX; m->x[2][1] = xform->CY; m->x[2][2] = xform->CZ;
00049 }

void Matrix33_GetInverse const Matrix33 m,
Matrix33 inv
 

Definition at line 159 of file matrix33.c.

References geFloat, Matrix33_Copy(), Matrix33_SetIdentity(), NULL, and Matrix33::x.

00160 {
00161         int i, j, k;
00162         Matrix33 copy;
00163 
00164         assert(m != NULL);
00165         assert(inv != NULL);
00166 
00167         Matrix33_Copy(m, &copy);
00168         Matrix33_SetIdentity(inv);
00169 
00170         for (i = 0; i < 3; i++)
00171         {
00172                 if (copy.x[i][i] != 1.0f)
00173                 {
00174                         geFloat divby = copy.x[i][i];
00175 
00176                         assert(fabs(divby) >= 1e-5);
00177                         
00178                         for (j = 0; j < 3; j++)
00179                         {
00180                                 inv->x[i][j] /= divby;
00181                                 copy.x[i][j] /= divby;
00182                         }
00183                 }
00184                 for (j = 0; j < 3; j++)
00185                 {
00186                         if (j != i)
00187                         {
00188                                 if (copy.x[j][i] != 0.0f)
00189                                 {
00190                                         geFloat mulby = copy.x[j][i];
00191                                         for (k = 0; k < 3; k++)
00192                                         {
00193                                                 copy.x[j][k] -= mulby * copy.x[i][k];
00194                                                 inv->x[j][k] -= mulby * inv->x[i][k];
00195                                         }
00196                                 }
00197                         }
00198                 }
00199         }
00200 }

void Matrix33_GetTranspose const Matrix33 m,
Matrix33 t
 

Definition at line 82 of file matrix33.c.

References NULL, t, and Matrix33::x.

Referenced by gePhysicsObject_ApplyGlobalFrameImpulse(), gePhysicsObject_GetInertiaTensorInPhysicsSpace(), gePhysicsObject_GetInertiaTensorInverseInPhysicsSpace(), gePhysicsObject_Integrate(), and gePhysicsSystem_EnforceConstraints().

00083 {
00084         int i, j;
00085 
00086         assert(m != NULL);
00087         assert(t != NULL);
00088 
00089         for (i = 0; i < 3; i++)
00090                 for (j = 0; j < 3; j++)
00091                         t->x[j][i] = m->x[i][j];
00092 }

void Matrix33_MakeCrossProductMatrix33 const geVec3d v,
Matrix33 m
 

Definition at line 29 of file matrix33.c.

References NULL, v, and Matrix33::x.

Referenced by gePhysicsSystem_EnforceConstraints().

00031 {
00032         assert(v != NULL);
00033         assert(m != NULL);
00034 
00035         m->x[0][0] = m->x[1][1] = m->x[2][2] = 0.0f;
00036         m->x[0][1] = -v->Z; m->x[0][2] = v->Y;
00037         m->x[1][0] = v->Z; m->x[1][2] = -v->X;
00038         m->x[2][0] = -v->Y; m->x[2][1] = v->X;
00039 }

void Matrix33_Multiply const Matrix33 m1,
const Matrix33 m2,
Matrix33 res
 

Definition at line 62 of file matrix33.c.

References NULL, and Matrix33::x.

Referenced by gePhysicsObject_GetInertiaTensorInPhysicsSpace(), gePhysicsObject_GetInertiaTensorInverseInPhysicsSpace(), and gePhysicsSystem_EnforceConstraints().

00063 {
00064         int i, j, k;
00065 
00066         assert(m1 != NULL);
00067         assert(m2 != NULL);
00068         assert(res != NULL);
00069 
00070         for (i = 0; i < 3; i++)
00071         {
00072                 for (j = 0; j < 3; j++)
00073                 {
00074                         res->x[i][j] = 0.0f;
00075 
00076                         for (k = 0; k < 3; k++)
00077                                 res->x[i][j] += m1->x[i][k] * m2->x[k][j];
00078                 }
00079         }
00080 }

void Matrix33_MultiplyScalar geFloat  s,
const Matrix33 m,
Matrix33 res
 

Definition at line 147 of file matrix33.c.

References NULL, s, and Matrix33::x.

Referenced by gePhysicsSystem_EnforceConstraints().

00148 {
00149         int i, j;
00150 
00151         assert(m != NULL);
00152         assert(res != NULL);
00153 
00154         for (i = 0; i < 3; i++)
00155                 for (j = 0; j < 3; j++)
00156                         res->x[i][j] = s * m->x[i][j];
00157 }

void Matrix33_MultiplyVec3d const Matrix33 m,
const geVec3d v,
geVec3d res
 

Definition at line 51 of file matrix33.c.

References NULL, v, geVec3d::X, Matrix33::x, geVec3d::Y, and geVec3d::Z.

Referenced by gePhysicsObject_ApplyGlobalFrameImpulse(), gePhysicsObject_Integrate(), gePhysicsSystem_EnforceConstraints(), and PhysicsObject_Control().

00052 {
00053         assert(m != NULL);
00054         assert(v != NULL);
00055         assert(res != NULL);
00056 
00057         res->X = m->x[0][0] * v->X + m->x[0][1] * v->Y + m->x[0][2] * v->Z;
00058         res->Y = m->x[1][0] * v->X + m->x[1][1] * v->Y + m->x[1][2] * v->Z;
00059         res->Z = m->x[2][0] * v->X + m->x[2][1] * v->Y + m->x[2][2] * v->Z;
00060 }

void Matrix33_SetIdentity Matrix33 m  ) 
 

Definition at line 106 of file matrix33.c.

References NULL, and Matrix33::x.

Referenced by gePhysicsObject_Create(), gePhysicsSystem_Create(), and Matrix33_GetInverse().

00107 {
00108         int i, j;
00109 
00110         assert(m != NULL);
00111 
00112         for (i = 0; i < 3; i++)
00113                 for (j = 0; j < 3; j++)
00114                 {
00115                         if (i == j) 
00116                                 m->x[i][j] = 1.f;
00117                         else m->x[i][j] = 0.f;
00118                 }
00119 }

void Matrix33_Subtract const Matrix33 m1,
const Matrix33 m2,
Matrix33 res
 

Definition at line 134 of file matrix33.c.

References NULL, and Matrix33::x.

Referenced by gePhysicsSystem_EnforceConstraints().

00135 {
00136         int i, j;
00137 
00138         assert(m1 != NULL);
00139         assert(m2 != NULL);
00140         assert(res != NULL);
00141 
00142         for (i = 0; i < 3; i++)
00143                 for (j = 0; j < 3; j++)
00144                         res->x[i][j] = m1->x[i][j] - m2->x[i][j];
00145 }


Generated on Tue Sep 30 12:37:46 2003 for GTestAndEngine by doxygen 1.3.2