added Dimension

This commit is contained in:
ganovelli 2005-01-12 11:25:02 +00:00
parent 5a7921fe9c
commit 99766e2bd0
1 changed files with 24 additions and 6 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.7 2004/10/11 17:46:11 ganovelli
added definition of vector product (not implemented)
Revision 1.6 2004/05/10 11:16:19 ganovelli Revision 1.6 2004/05/10 11:16:19 ganovelli
include assert.h added include assert.h added
@ -60,6 +63,7 @@ protected:
public: public:
typedef T ScalarType; typedef T ScalarType;
enum {Dimension = 4};
//@{ //@{
@ -186,10 +190,18 @@ public:
{ {
return Point4( -_v[0], -_v[1], -_v[2], -_v[3] ); return Point4( -_v[0], -_v[1], -_v[2], -_v[3] );
} }
inline Point4 operator ^ ( const Point4 t ) const inline Point4 VectProd ( const Point4 x, const Point4 z ) const
{ {
assert(0); Point4 res;
return Point4(); Matrix44<T> b;
*(vcg::Point4<T>*)&b[1][0] = *this;
*(vcg::Point4<T>*)&b[2][0] = x;
*(vcg::Point4<T>*)&b[3][0] = z;
res[0] = b[1][1]*b[2][2]*b[3][3]-b[1][1]*b[2][3]*b[3][2]-b[2][1]*b[1][2]*b[3][3]+ b[2][1]*b[1][3]*b[3][2]+b[3][1]*b[1][2]*b[2][3]-b[3][1]*b[1][3]*b[2][2]; res[1] = b[1][0]*b[2][3]*b[3][2]-b[3][0]*b[1][2]*b[2][3]-b[1][0]*b[2][2]*
b[3][3]+b[3][0]*b[1][3]*b[2][2]+b[2][0]*b[1][2]*b[3][3]-b[2][0]*b[1][3]*b[3][2]; res[2] = -b[1][0]*b[3][1]*b[2][3]+b[2][0]*b[3][1]*b[1][3]+b[1][0]*b[2][1]*
b[3][3]-b[2][0]*b[1][1]*b[3][3]-b[3][0]*b[2][1]*b[1][3]+b[3][0]*b[1][1]*b[2][3]; res[3] = -b[3][0]*b[1][1]*b[2][2]-b[1][0]*b[2][1]*b[3][2]+b[2][0]*b[1][1]*
b[3][2]+b[1][0]*b[3][1]*b[2][2]-b[2][0]*b[3][1]*b[1][2]+b[3][0]*b[2][1]*b[1][2]; return res;
} }
//@} //@}
@ -199,7 +211,7 @@ public:
/// Euclidian normal /// Euclidian normal
inline T Norm() const inline T Norm() const
{ {
return Sqrt( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] + _v[3]*_v[3] ); return math::Sqrt( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] + _v[3]*_v[3] );
} }
/// Squared euclidian normal /// Squared euclidian normal
inline T SquaredNorm() const inline T SquaredNorm() const
@ -209,7 +221,7 @@ public:
/// Euclidian normalization /// Euclidian normalization
inline Point4 & Normalize() inline Point4 & Normalize()
{ {
T n = Sqrt(_v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] + _v[3]*_v[3] ); T n = sqrt(_v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] + _v[3]*_v[3] );
if(n>0.0) { _v[0] /= n; _v[1] /= n; _v[2] /= n; _v[3] /= n; } if(n>0.0) { _v[0] /= n; _v[1] /= n; _v[2] /= n; _v[3] /= n; }
return *this; return *this;
} }
@ -271,6 +283,12 @@ public:
{ {
return _v[0]*p._v[0] + _v[1]*p._v[1] + _v[2]*p._v[2] + _v[3]*p._v[3]; return _v[0]*p._v[0] + _v[1]*p._v[1] + _v[2]*p._v[2] + _v[3]*p._v[3];
} }
inline Point4 operator ^ ( const Point4& p ) const
{
assert(0);// not defined by two vectors (only put for metaprogramming)
return Point4();
}
/// slower version, more stable (double precision only) /// slower version, more stable (double precision only)
T StableDot ( const Point4<T> & p ) const T StableDot ( const Point4<T> & p ) const
{ {