From d8032a9bc0e23264b65826d87fbe0300ee7cee54 Mon Sep 17 00:00:00 2001 From: ponchio Date: Fri, 8 Jun 2007 14:57:29 +0000 Subject: [PATCH] *** empty log message *** --- vcg/space/sphere3.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/vcg/space/sphere3.h b/vcg/space/sphere3.h index 90cd8c80..665f352e 100644 --- a/vcg/space/sphere3.h +++ b/vcg/space/sphere3.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.9 2006/07/06 12:40:34 ganovelli +typdef ..ScalarType added + Revision 1.8 2005/02/22 14:18:15 ponchio assert addded. @@ -90,6 +93,8 @@ protected: void Add(const Sphere3 &sphere); void Intersect(const Sphere3 &sphere); + + int CreateFromBox(int n, const Point3 *points); //makes 36 iterations over the data... but get good results. int CreateTight(int n, const Point3 *points, T threshold = 1.01, T speed = 0.6); @@ -161,6 +166,20 @@ template void Sphere3::Intersect(const Sphere3 &s) { _radius = r; } + template int Sphere3::CreateFromBox(int n, const Point3 *points) { + Point3f max(-1e100, -1e100, -1e100); + Point3f min(1e100, 1e100, 1e100); + for(int i = 0; i < n; i++) { + for(int k = 0; k < 3; k++) { + if(max[k] < points[i][k]) max[k] = points[i][k]; + if(min[k] > points[i][k]) min[k] = points[i][k]; + } + } + Center() = (min + max)/2; + Radius() = (min - max).Norm()/2; + return 0; + } + template int Sphere3::CreateTight(int n, const Point3 *points, T threshold, T speed) { //This is quantized gradient descent... really ugly. But simple :P