From 9b717655617463d977da720d3241b6c854da4e57 Mon Sep 17 00:00:00 2001 From: ponchio Date: Thu, 19 Feb 2004 14:58:23 +0000 Subject: [PATCH] Doxygen and minimal changes. --- vcg/math/matrix44.h | 54 ++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/vcg/math/matrix44.h b/vcg/math/matrix44.h index b82f832a..96d6c261 100644 --- a/vcg/math/matrix44.h +++ b/vcg/math/matrix44.h @@ -30,7 +30,17 @@ $LOG$ #ifndef __VCGLIB_MATRIX44 #define __VCGLIB_MATRIX44 -/* + + +#include +#include +#include "../space/Point3.h" +#include "../space/Point4.h" + + +namespace vcg { + + /* Annotations: Opengl stores matrix in column-major order. That is, the matrix is stored as: @@ -60,19 +70,10 @@ and the Translate Function generate: 0 0 1 0 tx ty tz 1 -Le funzioni Translate e Rotate vanno usate con la Apply, -che moltiplica vettore (inteso come riga) per la matrice - */ -#include -#include -#include "../space/Point3.h" -#include "../space/Point4.h" - - -namespace vcg { - + /** This class represent a 4x4 matrix. T is the kind of element in the matrix. + */ template class Matrix44 { protected: T _a[16]; @@ -80,6 +81,11 @@ protected: public: typedef T scalar; +///@{ + + /** $name Contrutors + * No automatic casting and default constructor is empty + */ Matrix44() {}; ~Matrix44() {}; Matrix44(const Matrix44 &m); @@ -111,27 +117,39 @@ public: void SetScale(const T sx, const T sy, const T sz); void SetTranslate(const Point3 &t); void SetTranslate(const T sx, const T sy, const T sz); - void SetRotate(T angle, const Point3 & axis); //use radiants for angle. + ///use radiants for angle. + void SetRotate(T angle, const Point3 & axis); T Determinant() const; }; +/** Class for solving A * x = b. */ template class LinearSolve: public Matrix44 { public: LinearSolve(const Matrix44 &m); - Point4 Solve(Point4 &b); // solve A · x = b + Point4 Solve(const Point4 &b); // solve A · x = b + ///If you need to solve some equation you can use this function instead of Matrix44 one for speed. T Determinant() const; protected: + ///Holds row permutation. int index[4]; //hold permutation - T d; //hold sign of permutation + ///Hold sign of row permutation (used for determinant sign) + T d; void Decompose(); }; +/// Apply POST moltiplica la matrice al vettore (e.g. la traslazione deve stare nell'ultima riga) +/// Project PRE moltiplica la matrice al vettore (e.g. la traslazione deve stare nell'ultima colonna) -template Point4 operator*(const Matrix44 &m, const Point4 &p); +/*** Postmultiply (old Apply in the old interface). + * SetTranslate, SetScale, SetRotate prepare the matrix for this. + */ template Point4 operator*(const Point4 &p, const Matrix44 &m); +///Premultiply (old Project in the old interface) +template Point4 operator*(const Matrix44 &m, const Point4 &p); + template Matrix44 &Transpose(Matrix44 &m); template Matrix44 &Invert(Matrix44 &m); @@ -140,7 +158,7 @@ typedef Matrix44 Matrix44i; typedef Matrix44 Matrix44f; typedef Matrix44 Matrix44d; -//Implementazione + template Matrix44::Matrix44(const Matrix44 &m) { memcpy((T *)_a, (T *)m._a, 16 * sizeof(T)); @@ -450,7 +468,7 @@ template void LinearSolve::Decompose() { } -template Point4 LinearSolve::Solve(Point4 &b) { +template Point4 LinearSolve::Solve(const Point4 &b) { Point4 x(b); int first = 0, ip; for(int i = 0; i < 4; i++) {