Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

math3d.cpp

Go to the documentation of this file.
00001 #include "sysdep.h"
00002 #include "math3d.h"
00003 
00004 const Vector3D Vector3D::Zero(0.0f,0.0f,0.0f);
00005 const Matrix3D Matrix3D::Identity(1.0f,0.0f,0.0f,0.0f,
00006                                   0.0f,1.0f,0.0f,0.0f,
00007                                   0.0f,0.0f,1.0f,0.0f,
00008                                   0.0f,0.0f,0.0f,1.0f);
00009 
00010 
00011 inline float
00012 MINOR(const Matrix3D& m, const int r0, const int r1, const int r2, const int c0, const int c1, const int c2)
00013 {
00014    return m(r0,c0) * (m(r1,c1) * m(r2,c2) - m(r2,c1) * m(r1,c2)) -
00015           m(r0,c1) * (m(r1,c0) * m(r2,c2) - m(r2,c0) * m(r1,c2)) +
00016           m(r0,c2) * (m(r1,c0) * m(r2,c1) - m(r2,c0) * m(r1,c1));
00017 }
00018 
00019 
00020 Matrix3D
00021 Matrix3D::Adjoint() const
00022 {
00023    return Matrix3D( MINOR(*this, 1, 2, 3, 1, 2, 3),
00024                    -MINOR(*this, 0, 2, 3, 1, 2, 3),
00025                     MINOR(*this, 0, 1, 3, 1, 2, 3),
00026                    -MINOR(*this, 0, 1, 2, 1, 2, 3),
00027 
00028                    -MINOR(*this, 1, 2, 3, 0, 2, 3),
00029                     MINOR(*this, 0, 2, 3, 0, 2, 3),
00030                    -MINOR(*this, 0, 1, 3, 0, 2, 3),
00031                     MINOR(*this, 0, 1, 2, 0, 2, 3),
00032 
00033                     MINOR(*this, 1, 2, 3, 0, 1, 3),
00034                    -MINOR(*this, 0, 2, 3, 0, 1, 3),
00035                     MINOR(*this, 0, 1, 3, 0, 1, 3),
00036                    -MINOR(*this, 0, 1, 2, 0, 1, 3),
00037 
00038                    -MINOR(*this, 1, 2, 3, 0, 1, 2),
00039                     MINOR(*this, 0, 2, 3, 0, 1, 2),
00040                    -MINOR(*this, 0, 1, 3, 0, 1, 2),
00041                     MINOR(*this, 0, 1, 2, 0, 1, 2));
00042 }
00043 
00044 
00045 float
00046 Matrix3D::Determinant() const
00047 {
00048    return m[0][0] * MINOR(*this, 1, 2, 3, 1, 2, 3) -
00049           m[0][1] * MINOR(*this, 1, 2, 3, 0, 2, 3) +
00050           m[0][2] * MINOR(*this, 1, 2, 3, 0, 1, 3) -
00051           m[0][3] * MINOR(*this, 1, 2, 3, 0, 1, 2);
00052 }
00053 
00054 Matrix3D 
00055 Matrix3D::Inverse() const
00056 {
00057    return (1.0f / Determinant()) * Adjoint();
00058 }
00059 

Generated at Sat Nov 18 00:15:14 2000 for coldet by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000