From 7ea2f49da5206ae61263271438d293ba73e3ca39 Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 7 Apr 2004 10:45:54 +0000 Subject: [PATCH] Added: [i][j] access, V() for the raw float values, constructor from T[16] --- vcg/math/matrix44.h | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/vcg/math/matrix44.h b/vcg/math/matrix44.h index 9fef05c1..8871e4db 100644 --- a/vcg/math/matrix44.h +++ b/vcg/math/matrix44.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.12 2004/03/25 14:57:49 ponchio +Microerror. ($LOG$ -> $Log: not supported by cvs2svn $ + ****************************************************************************/ @@ -90,8 +93,13 @@ public: T &element(const int row, const int col); T element(const int row, const int col) const; - T &operator[](const int i); - const T &operator[](const int i) const; + //T &operator[](const int i); + //const T &operator[](const int i) const; + T *V(); + const T *V() const ; + + T *operator[](const int i); + const T *operator[](const int i) const; Matrix44 operator+(const Matrix44 &m) const; Matrix44 operator-(const Matrix44 &m) const; @@ -121,7 +129,7 @@ public: template void Import(const Matrix44 &m) { for(int i = 0; i < 16; i++) - _a[i] = (T)m._a[i]; + _a[i] = (T)(m.V()[i]); } }; @@ -168,6 +176,10 @@ template Matrix44::Matrix44(const Matrix44 &m) { memcpy((T *)_a, (T *)m._a, 16 * sizeof(T)); } +template Matrix44::Matrix44(const T v[]) { + memcpy((T *)_a, v, 16 * sizeof(T)); +} + template T &Matrix44::element(const int row, const int col) { assert(row >= 0 && row < 4); assert(col >= 0 && col < 4); @@ -180,15 +192,27 @@ template T Matrix44::element(const int row, const int col) const { return _a[(row<<2) + col]; } -template T &Matrix44::operator[](const int i) { +//template T &Matrix44::operator[](const int i) { +// assert(i >= 0 && i < 16); +// return ((T *)_a)[i]; +//} +// +//template const T &Matrix44::operator[](const int i) const { +// assert(i >= 0 && i < 16); +// return ((T *)_a)[i]; +//} +template T *Matrix44::operator[](const int i) { assert(i >= 0 && i < 16); - return ((T *)_a)[i]; + return _a+i*4; } -template const T &Matrix44::operator[](const int i) const { - assert(i >= 0 && i < 16); - return ((T *)_a)[i]; +template const T *Matrix44::operator[](const int i) const { + assert(i >= 0 && i < 4); + return _a+i*4; } +template T *Matrix44::V() { return _a;} +template const T *Matrix44::V() const { return _a;} + template Matrix44 Matrix44::operator+(const Matrix44 &m) const { Matrix44 ret;