00001 #ifndef BEST_FIT_H 00002 00003 #define BEST_FIT_H 00004 00005 // This routine was released in 'snippet' form 00006 // by John W. Ratcliff mailto:jratcliff@infiniplex.net 00007 // on March 22, 2006. 00008 // 00009 // This routine computes the 'best fit' plane equation to 00010 // a set of input data points with an optional per vertex 00011 // weighting component. 00012 // 00013 // The implementation for this was lifted directly from 00014 // David Eberly's Magic Software implementation. 00015 00016 // computes the best fit plane to a collection of data points. 00017 // returns the plane equation as A,B,C,D format. (Ax+By+Cz+D) 00018 00073 namespace ConvexDecomposition 00074 { 00075 00076 00077 bool getBestFitPlane(unsigned int vcount, // number of input data points 00078 const double *points, // starting address of points array. 00079 unsigned int vstride, // stride between input points. 00080 const double *weights, // *optional point weighting values. 00081 unsigned int wstride, // weight stride for each vertex. 00082 double *plane); 00083 00084 00085 double getBoundingRegion(unsigned int vcount,const double *points,unsigned int pstride,double *bmin,double *bmax); // returns the diagonal distance 00086 bool overlapAABB(const double *bmin1,const double *bmax1,const double *bmin2,const double *bmax2); // return true if the two AABB's overlap. 00087 00088 }; 00089 00090 #endif