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

@ -98,6 +98,8 @@ protected:
//makes 36 iterations over the data... but get good results.
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);
};
template <class T> T Distance(const Sphere3<T> &sphere,
@ -179,7 +181,6 @@ template <class T> void Sphere3<T>::Intersect(const Sphere3<T> &s) {
Radius() = (min - max).Norm()/2;
return 0;
}
template <class T> int Sphere3<T>::CreateTight(int n, const Point3<T> *points,
T threshold, T speed) {
//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;
}
step *= speed;
if(step < Radius() * (threshold - 1))
if(step <= Radius() * (threshold - 1))
break;
}
Radius() *= 1.01;
@ -238,6 +239,11 @@ template <class T> void Sphere3<T>::Intersect(const Sphere3<T> &s) {
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