00001 // Wild Magic Source Code 00002 // David Eberly 00003 // http://www.geometrictools.com 00004 // Copyright (c) 1998-2007 00005 // 00006 // This library is free software; you can redistribute it and/or modify it 00007 // under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation; either version 2.1 of the License, or (at 00009 // your option) any later version. The license is available for reading at 00010 // either of the locations: 00011 // http://www.gnu.org/copyleft/lgpl.html 00012 // http://www.geometrictools.com/License/WildMagicLicense.pdf 00013 // The license applies to versions 0 through 4 of Wild Magic. 00014 // 00015 // Version: 4.0.0 (2006/06/28) 00016 00017 #ifndef WM4APPRSPHEREFIT3_H 00018 #define WM4APPRSPHEREFIT3_H 00019 00020 #include "Wm4FoundationLIB.h" 00021 #include "Wm4Sphere3.h" 00022 00023 namespace Wm4 00024 { 00025 00026 // Least-squares fit of a sphere to a set of points. Successful fit is 00027 // indicated by return value of 'true'. If return value is false, number of 00028 // iterations was exceeded. Try increasing the maximum number of iterations. 00029 // 00030 // If bInitialCenterIsAverage is set to 'true', the initial guess for the 00031 // sphere center is the average of the data points. If the data points are 00032 // clustered along a solid angle, SphereFit3 is very slow to converge. If 00033 // bInitialCenterIsAverage is set to 'false', the initial guess for the 00034 // sphere center is computed using a least-squares estimate of the 00035 // coefficients for a quadratic equation that represents a sphere. This 00036 // approach tends to converge rapidly. 00037 00038 template <class Real> WM4_FOUNDATION_ITEM 00039 bool SphereFit3 (int iQuantity, const Vector3<Real>* akPoint, 00040 int iMaxIterations, Sphere3<Real>& rkSphere, 00041 bool bInitialCenterIsAverage); 00042 00043 } 00044 00045 #endif