From 8da5fad88422e766fb7a09a294c4f1c1c5956324 Mon Sep 17 00:00:00 2001 From: ponchio Date: Fri, 21 Jan 2005 18:02:11 +0000 Subject: [PATCH] Removed dependence from matrix44 and changed VectProd --- vcg/space/point4.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/vcg/space/point4.h b/vcg/space/point4.h index 93f7ddad..566ddbff 100644 --- a/vcg/space/point4.h +++ b/vcg/space/point4.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.8 2005/01/12 11:25:02 ganovelli +added Dimension + Revision 1.7 2004/10/11 17:46:11 ganovelli added definition of vector product (not implemented) @@ -190,18 +193,20 @@ public: { return Point4( -_v[0], -_v[1], -_v[2], -_v[3] ); } - inline Point4 VectProd ( const Point4 x, const Point4 z ) const + inline Point4 VectProd ( const Point4 &x, const Point4 &z ) const { Point4 res; - Matrix44 b; - *(vcg::Point4*)&b[1][0] = *this; - *(vcg::Point4*)&b[2][0] = x; - *(vcg::Point4*)&b[3][0] = z; + const Point4 &y = *this; - 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; + res[0] = y[1]*x[2]*z[3]-y[1]*x[3]*z[2]-x[1]*y[2]*z[3]+ + x[1]*y[3]*z[2]+z[1]*y[2]*x[3]-z[1]*y[3]*x[2]; + res[1] = y[0]*x[3]*z[2]-z[0]*y[2]*x[3]-y[0]*x[2]* + z[3]+z[0]*y[3]*x[2]+x[0]*y[2]*z[3]-x[0]*y[3]*z[2]; + res[2] = -y[0]*z[1]*x[3]+x[0]*z[1]*y[3]+y[0]*x[1]* + z[3]-x[0]*y[1]*z[3]-z[0]*x[1]*y[3]+z[0]*y[1]*x[3]; + res[3] = -z[0]*y[1]*x[2]-y[0]*x[1]*z[2]+x[0]*y[1]* + z[2]+y[0]*z[1]*x[2]-x[0]*z[1]*y[2]+z[0]*x[1]*y[2]; + return res; } //@}