QTrk
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Matrix3X3 Class Reference

#include <utils.h>

Public Member Functions

 Matrix3X3 ()
 
 Matrix3X3 (vector3f x, vector3f y, vector3f z)
 
vector3f diag () const
 
float & operator[] (int i)
 
const float & operator[] (int i) const
 
vector3frow (int i)
 
const vector3frow (int i) const
 
float & operator() (int i, int j)
 
const float & operator() (int i, int j) const
 
float & at (int i, int j)
 
const float & at (int i, int j) const
 
float Determinant () const
 
Matrix3X3 Inverse () const
 
Matrix3X3 InverseTranspose () const
 
Matrix3X3operator*= (float a)
 
Matrix3X3operator+= (const Matrix3X3 &b)
 
void dbgprint ()
 

Static Public Member Functions

static void test ()
 

Public Attributes

float m [9]
 

Detailed Description

Definition at line 267 of file utils.h.

Constructor & Destructor Documentation

§ Matrix3X3() [1/2]

Matrix3X3::Matrix3X3 ( )
inline

Definition at line 270 of file utils.h.

270 { for(int i=0;i<9;i++) m[i]=0.0f; }
float m[9]
Definition: utils.h:349

§ Matrix3X3() [2/2]

Matrix3X3::Matrix3X3 ( vector3f  x,
vector3f  y,
vector3f  z 
)
inline

Definition at line 271 of file utils.h.

271  {
272  row(0) = x;
273  row(1) = y;
274  row(2) = z;
275  }
vector3f & row(int i)
Definition: utils.h:282

Member Function Documentation

§ at() [1/2]

float& Matrix3X3::at ( int  i,
int  j 
)
inline

Definition at line 288 of file utils.h.

288 { return m[3*i+j]; }
float m[9]
Definition: utils.h:349

§ at() [2/2]

const float& Matrix3X3::at ( int  i,
int  j 
) const
inline

Definition at line 289 of file utils.h.

289 { return m[3*i+j]; }
float m[9]
Definition: utils.h:349

§ dbgprint()

void Matrix3X3::dbgprint ( )
inline

Definition at line 360 of file utils.h.

361  {
362  dbgprintf("%f\t%f\t%f\n", m[0],m[1],m[2]);
363  dbgprintf("%f\t%f\t%f\n", m[3],m[4],m[5]);
364  dbgprintf("%f\t%f\t%f\n", m[6],m[7],m[8]);
365  }
void dbgprintf(const char *fmt,...)
Definition: utils.cpp:149
float m[9]
Definition: utils.h:349

§ Determinant()

float Matrix3X3::Determinant ( ) const
inline

Definition at line 291 of file utils.h.

292  {
293  return at(0,0)*(at(1,1)*at(2,2)-at(2,1)*at(1,2))
294  -at(0,1)*(at(1,0)*at(2,2)-at(1,2)*at(2,0))
295  +at(0,2)*(at(1,0)*at(2,1)-at(1,1)*at(2,0));
296  }
float & at(int i, int j)
Definition: utils.h:288

§ diag()

vector3f Matrix3X3::diag ( ) const
inline

Definition at line 277 of file utils.h.

277 { return vector3f(at(0,0),at(1,1),at(2,2)); }
vector3< float > vector3f
Definition: std_incl.h:114
float & at(int i, int j)
Definition: utils.h:288

§ Inverse()

Matrix3X3 Matrix3X3::Inverse ( ) const
inline

Definition at line 298 of file utils.h.

299  {
300  float det = Determinant();
301  if (det != 0.0f) {
302  float invdet = 1/det;
303  Matrix3X3 result;
304  result(0,0) = (at(1,1)*at(2,2)-at(2,1)*at(1,2))*invdet;
305  result(1,0) = -(at(0,1)*at(2,2)-at(0,2)*at(2,1))*invdet;
306  result(2,0) = (at(0,1)*at(1,2)-at(0,2)*at(1,1))*invdet;
307  result(0,1) = -(at(1,0)*at(2,2)-at(1,2)*at(2,0))*invdet;
308  result(1,1) = (at(0,0)*at(2,2)-at(0,2)*at(2,0))*invdet;
309  result(2,1) = -(at(0,0)*at(1,2)-at(1,0)*at(0,2))*invdet;
310  result(0,2) = (at(1,0)*at(2,1)-at(2,0)*at(1,1))*invdet;
311  result(1,2) = -(at(0,0)*at(2,1)-at(2,0)*at(0,1))*invdet;
312  result(2,2) = (at(0,0)*at(1,1)-at(1,0)*at(0,1))*invdet;
313  return result;
314  }
315  return Matrix3X3();
316  }
Matrix3X3()
Definition: utils.h:270
float Determinant() const
Definition: utils.h:291
float & at(int i, int j)
Definition: utils.h:288

§ InverseTranspose()

Matrix3X3 Matrix3X3::InverseTranspose ( ) const
inline

Definition at line 317 of file utils.h.

318  {
319  float det = Determinant();
320  if (det != 0.0f) {
321  float invdet = 1/det;
322  Matrix3X3 result;
323  result(0,0) = (at(1,1)*at(2,2)-at(2,1)*at(1,2))*invdet;
324  result(0,1) = -(at(0,1)*at(2,2)-at(0,2)*at(2,1))*invdet;
325  result(0,2) = (at(0,1)*at(1,2)-at(0,2)*at(1,1))*invdet;
326  result(1,0) = -(at(1,0)*at(2,2)-at(1,2)*at(2,0))*invdet;
327  result(1,1) = (at(0,0)*at(2,2)-at(0,2)*at(2,0))*invdet;
328  result(1,2) = -(at(0,0)*at(1,2)-at(1,0)*at(0,2))*invdet;
329  result(2,0) = (at(1,0)*at(2,1)-at(2,0)*at(1,1))*invdet;
330  result(2,1) = -(at(0,0)*at(2,1)-at(2,0)*at(0,1))*invdet;
331  result(2,2) = (at(0,0)*at(1,1)-at(1,0)*at(0,1))*invdet;
332  return result;
333  }
334  return Matrix3X3();
335  }
Matrix3X3()
Definition: utils.h:270
float Determinant() const
Definition: utils.h:291
float & at(int i, int j)
Definition: utils.h:288

§ operator()() [1/2]

float& Matrix3X3::operator() ( int  i,
int  j 
)
inline

Definition at line 285 of file utils.h.

285 { return m[3*i+j]; }
float m[9]
Definition: utils.h:349

§ operator()() [2/2]

const float& Matrix3X3::operator() ( int  i,
int  j 
) const
inline

Definition at line 286 of file utils.h.

286 { return m[3*i+j]; }
float m[9]
Definition: utils.h:349

§ operator*=()

Matrix3X3& Matrix3X3::operator*= ( float  a)
inline

Definition at line 337 of file utils.h.

337  {
338  for(int i=0;i<9;i++)
339  m[i]*=a;
340  return *this;
341  }
float m[9]
Definition: utils.h:349

§ operator+=()

Matrix3X3& Matrix3X3::operator+= ( const Matrix3X3 b)
inline

Definition at line 343 of file utils.h.

343  {
344  for(int i=0;i<9;i++)
345  m[i]+=b[i];
346  return *this;
347  }
float m[9]
Definition: utils.h:349

§ operator[]() [1/2]

float& Matrix3X3::operator[] ( int  i)
inline

Definition at line 279 of file utils.h.

279 { return m[i]; }
float m[9]
Definition: utils.h:349

§ operator[]() [2/2]

const float& Matrix3X3::operator[] ( int  i) const
inline

Definition at line 280 of file utils.h.

280 { return m[i]; }
float m[9]
Definition: utils.h:349

§ row() [1/2]

vector3f& Matrix3X3::row ( int  i)
inline

Definition at line 282 of file utils.h.

282 { return *(vector3f*)&m[i*3]; }
float m[9]
Definition: utils.h:349

§ row() [2/2]

const vector3f& Matrix3X3::row ( int  i) const
inline

Definition at line 283 of file utils.h.

283 { return *(vector3f*)&m[i*3]; }
float m[9]
Definition: utils.h:349

§ test()

static void Matrix3X3::test ( )
inlinestatic

Definition at line 351 of file utils.h.

352  {
353  Matrix3X3 t;
354 
355  for (int i=0;i<9;i++)
356  t[i]=i*i;
357  t.Inverse().dbgprint();
358  }
void dbgprint()
Definition: utils.h:360
Matrix3X3 Inverse() const
Definition: utils.h:298

Member Data Documentation

§ m

float Matrix3X3::m[9]

Definition at line 349 of file utils.h.


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