bestfit.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef BEST_FIT_H
  2. #define BEST_FIT_H
  3. /*----------------------------------------------------------------------
  4. Copyright (c) 2004 Open Dynamics Framework Group
  5. www.physicstools.org
  6. All rights reserved.
  7. Redistribution and use in source and binary forms, with or without modification, are permitted provided
  8. that the following conditions are met:
  9. Redistributions of source code must retain the above copyright notice, this list of conditions
  10. and the following disclaimer.
  11. Redistributions in binary form must reproduce the above copyright notice,
  12. this list of conditions and the following disclaimer in the documentation
  13. and/or other materials provided with the distribution.
  14. Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
  15. be used to endorse or promote products derived from this software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
  17. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  21. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. -----------------------------------------------------------------------*/
  24. // http://codesuppository.blogspot.com
  25. //
  26. // mailto: [email protected]
  27. //
  28. // http://www.amillionpixels.us
  29. //
  30. // This routine was released in 'snippet' form
  31. // by John W. Ratcliff mailto:[email protected]
  32. // on March 22, 2006.
  33. //
  34. // This routine computes the 'best fit' plane equation to
  35. // a set of input data points with an optional per vertex
  36. // weighting component.
  37. //
  38. // The implementation for this was lifted directly from
  39. // David Eberly's Magic Software implementation.
  40. // computes the best fit plane to a collection of data points.
  41. // returns the plane equation as A,B,C,D format. (Ax+By+Cz+D)
  42. bool getBestFitPlane(unsigned int vcount, // number of input data points
  43. const float *points, // starting address of points array.
  44. unsigned int vstride, // stride between input points.
  45. const float *weights, // *optional point weighting values.
  46. unsigned int wstride, // weight stride for each vertex.
  47. float *plane);
  48. float getBoundingRegion(unsigned int vcount,const float *points,unsigned int pstride,float *bmin,float *bmax); // returns the diagonal distance
  49. bool overlapAABB(const float *bmin1,const float *bmax1,const float *bmin2,const float *bmax2); // return true if the two AABB's overlap.
  50. #endif