From 605c4d2f04f8874b1074e248f252e55b68cb8411 Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 9 Oct 2006 20:23:00 +0000 Subject: [PATCH] Added a minimum method that uses SVD. Unfortunately it is much much slower. --- vcg/math/quadric.h | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/vcg/math/quadric.h b/vcg/math/quadric.h index 822d6b52..2b25ff36 100644 --- a/vcg/math/quadric.h +++ b/vcg/math/quadric.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.5 2004/12/10 01:31:59 cignoni +added an alternative QuadricMinimization (we should use LRU decomposition!!) + Revision 1.3 2004/10/25 16:23:51 ponchio typedef ScalarType ScalarType; was a problem on g++ @@ -94,7 +97,7 @@ template< class PlaneType > void operator = ( const Quadric & q ) // Assegna una quadrica { - assert( IsValid() ); + //assert( IsValid() ); assert( q.IsValid() ); a[0] = q.a[0]; @@ -144,9 +147,10 @@ template */ /* Versione veloce */ - return p[0]*p[0]*a[0] + 2*p[0]*p[1]*a[1] + 2*p[0]*p[2]*a[2] + p[0]*b[0] - + p[1]*p[1]*a[3] + 2*p[1]*p[2]*a[4] + p[1]*b[1] - + p[2]*p[2]*a[5] + p[2]*b[2] + c; + return ResultScalarType ( + p[0]*p[0]*a[0] + 2*p[0]*p[1]*a[1] + 2*p[0]*p[2]*a[2] + p[0]*b[0] + + p[1]*p[1]*a[3] + 2*p[1]*p[2]*a[4] + p[1]*b[1] + + p[2]*p[2]*a[5] + p[2]*b[2] + c); } // spostare..risolve un sistema 3x3 @@ -227,6 +231,24 @@ bool Minimum(Point3 &x) return Gauss33(&(x[0]),C); } +// determina il punto di errore minimo usando le fun di inversione di matrice che usano svd +// Molto + lento +template +bool MinimumSVD(Point3 &x) +{ + Matrix33 C; + C[0][0]=a[0]; C[0][1]=a[1]; C[0][2]=a[2]; + C[1][0]=a[1]; C[1][1]=a[3]; C[1][2]=a[4]; + C[2][0]=a[2]; C[2][1]=a[4]; C[2][2]=a[5]; + Invert(C); + + C[0][3]=-b[0]/2; + C[1][3]=-b[1]/2; + C[2][3]=-b[2]/2; + x = C * Point3(-b[0]/2,-b[1]/2,-b[2]/2) ; + return true; +} + bool MinimumNew(Point3 &x) const {