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:jratcliffscarab@gmail.com 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 // 00019 // Geometric Tools, Inc. 00020 // http://www.geometrictools.com 00021 // Copyright (c) 1998-2006. All Rights Reserved 00022 // 00023 // The Wild Magic Library (WM3) source code is supplied under the terms of 00024 // the license agreement 00025 // http://www.geometrictools.com/License/WildMagic3License.pdf 00026 // and may not be copied or disclosed except in accordance with the terms 00027 // of that agreement. 00028 00029 00084 // A version that works with double precision floats. 00085 00086 bool getBestFitPlane(unsigned int vcount, // number of input data points 00087 const double *points, // starting address of points array. 00088 unsigned int vstride, // stride between input points. 00089 const double *weights, // *optional point weighting values. 00090 unsigned int wstride, // weight stride for each vertex. 00091 double *plane); 00092 00093 // A version that works with single precision floats. 00094 bool getBestFitPlane(unsigned int vcount, // number of input data points 00095 const float *points, // starting address of points array. 00096 unsigned int vstride, // stride between input points. 00097 const float *weights, // *optional point weighting values. 00098 unsigned int wstride, // weight stride for each vertex. 00099 float *plane); 00100 00101 00102 #endif