]> git.tdb.fi Git - libs/math.git/commitdiff
Fix the bounding sphere algorithm
authorMikko Rasa <tdb@tdb.fi>
Wed, 10 Dec 2014 18:32:47 +0000 (20:32 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 10 Dec 2014 18:32:47 +0000 (20:32 +0200)
source/geometry/boundingsphere.h

index dd20d96b6a4b701206f9e27b56a16cfc1402c158..b27e3a1bea7813bc3454f919471f8a1b79c09ca3 100644 (file)
@@ -83,8 +83,8 @@ BoundingSphere<T, N> BoundingSphere<T, N>::from_point_cloud(const Iter &begin, c
                if(d>sqdist)
                {
                        d = sqrt(d);
-                       bsphere.center += v*(1-bsphere.radius/d);
-                       bsphere.radius += d/2;
+                       bsphere.center += v*((T(1)-bsphere.radius/d)/T(2));
+                       bsphere.radius = (bsphere.radius+d)/T(2);
                        sqdist = bsphere.radius*bsphere.radius;
                }
        }