X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgeometry%2Fboundingsphere.h;h=66c14d5c904776f68c7344e76e534e1638e4f933;hb=44a1fb77d9199ce76fec21ee8aaa6df38e141bf0;hp=dd20d96b6a4b701206f9e27b56a16cfc1402c158;hpb=7fed55840f8482f8aa961f06f3f8f5b5af2d85c1;p=libs%2Fmath.git diff --git a/source/geometry/boundingsphere.h b/source/geometry/boundingsphere.h index dd20d96..66c14d5 100644 --- a/source/geometry/boundingsphere.h +++ b/source/geometry/boundingsphere.h @@ -22,7 +22,7 @@ public: template static BoundingSphere from_point_cloud(const Iter &, const Iter &); - const LinAl::Vector get_center() const { return center; } + const LinAl::Vector &get_center() const { return center; } T get_radius() const { return radius; } bool is_empty() const { return empty; } }; @@ -83,8 +83,8 @@ BoundingSphere BoundingSphere::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; } }