added a version of CreateTight which takes a std::vector

This commit is contained in:
ganovelli 2008-08-04 10:50:53 +00:00
parent e17c0de7e8
commit 08cdd7b3aa
1 changed files with 9 additions and 3 deletions

View File

@ -96,7 +96,9 @@ protected:
int CreateFromBox(int n, const Point3<T> *points); int CreateFromBox(int n, const Point3<T> *points);
//makes 36 iterations over the data... but get good results. //makes 36 iterations over the data... but get good results.
int CreateTight(int n, const Point3<T> *points, int CreateTight(int n, const Point3<T> *points,
T threshold = 1.01, T speed = 0.6);
int CreateTight(const std::vector<Point3<T> > & points,
T threshold = 1.01, T speed = 0.6); T threshold = 1.01, T speed = 0.6);
}; };
@ -179,7 +181,6 @@ template <class T> void Sphere3<T>::Intersect(const Sphere3<T> &s) {
Radius() = (min - max).Norm()/2; Radius() = (min - max).Norm()/2;
return 0; return 0;
} }
template <class T> int Sphere3<T>::CreateTight(int n, const Point3<T> *points, template <class T> int Sphere3<T>::CreateTight(int n, const Point3<T> *points,
T threshold, T speed) { T threshold, T speed) {
//This is quantized gradient descent... really ugly. But simple :P //This is quantized gradient descent... really ugly. But simple :P
@ -226,7 +227,7 @@ template <class T> void Sphere3<T>::Intersect(const Sphere3<T> &s) {
Radius() = best_radius; Radius() = best_radius;
} }
step *= speed; step *= speed;
if(step < Radius() * (threshold - 1)) if(step <= Radius() * (threshold - 1))
break; break;
} }
Radius() *= 1.01; Radius() *= 1.01;
@ -238,6 +239,11 @@ template <class T> void Sphere3<T>::Intersect(const Sphere3<T> &s) {
return count; return count;
} }
template <class T> int Sphere3<T>::CreateTight(const std::vector<Point3<T> > & points,
T threshold, T speed){
return (points.empty())? -1 :CreateTight(points.size(),&(*points.begin()),threshold,speed);
}
} //namespace } //namespace