PlaneFitting returns the eigenvalues instead of true now.
This commit is contained in:
parent
0b6af20c93
commit
75ee76b233
|
@ -46,7 +46,7 @@ created
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
bool PlaneFittingPoints( std::vector< Point3<S> > & samples,Plane3<S> &p){
|
Point3<S> PlaneFittingPoints( std::vector< Point3<S> > & samples,Plane3<S> &p){
|
||||||
|
|
||||||
int j;
|
int j;
|
||||||
Matrix44<S> m;m.SetZero();
|
Matrix44<S> m;m.SetZero();
|
||||||
|
@ -73,17 +73,25 @@ bool PlaneFittingPoints( std::vector< Point3<S> > & samples,Plane3<S> &p){
|
||||||
Point3<S> d;
|
Point3<S> d;
|
||||||
Jacobi(m,e,res,n);
|
Jacobi(m,e,res,n);
|
||||||
|
|
||||||
S mx = fabs(e[0]); int mxi=0;
|
//Sort eigenvalues (tarinisort)
|
||||||
for(j=1; j < 3; ++j) if( (fabs(e[j]) < mx) ) {mx=fabs(e[j]); mxi = j;}
|
e[0] = fabs(e[0]);
|
||||||
|
e[1] = fabs(e[1]);
|
||||||
d[0]=res[0][mxi];
|
e[2] = fabs(e[2]);
|
||||||
d[1]=res[1][mxi];
|
Point3<S> eval;
|
||||||
d[2]=res[2][mxi];
|
int maxi,mini,medi;
|
||||||
|
if (e[1] > e[0]) { maxi=1; mini=0; } else { maxi=0; mini=1;}
|
||||||
|
if (e[maxi] < e[2]) maxi=2; else if(e[mini] > e[2]) mini=2;
|
||||||
|
medi = 3 - maxi -mini;
|
||||||
|
eval = Point3<S>(e[mini], e[medi], e[maxi]);
|
||||||
|
|
||||||
|
d[0]=res[0][mini];
|
||||||
|
d[1]=res[1][mini];
|
||||||
|
d[2]=res[2][mini];
|
||||||
|
|
||||||
p.SetOffset(c*d/d.Norm());
|
p.SetOffset(c*d/d.Norm());
|
||||||
p.SetDirection(d/d.Norm());
|
p.SetDirection(d/d.Norm());
|
||||||
|
|
||||||
return true;
|
return eval;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class S>
|
template<class S>
|
||||||
|
|
Loading…
Reference in New Issue