private:
LinAl::Vector<T, N> center;
T radius;
+ bool empty;
public:
- BoundingSphere(): radius(0) { }
+ BoundingSphere();
BoundingSphere(const LinAl::Vector<T, N> &, T);
template<typename Iter>
const LinAl::Vector<T, N> get_center() const { return center; }
T get_radius() const { return radius; }
+ bool is_empty() const { return empty; }
};
+template<typename T, unsigned N>
+BoundingSphere<T, N>::BoundingSphere():
+ radius(0),
+ empty(true)
+{ }
+
template<typename T, unsigned N>
BoundingSphere<T, N>::BoundingSphere(const LinAl::Vector<T, N> &c, T r):
center(c),
- radius(r)
+ radius(r),
+ empty(false)
{ }
template<typename T, unsigned N>
{
using std::sqrt;
+ if(begin==end)
+ return BoundingSphere<T, N>();
+
LinAl::Vector<T, N> p1;
T sqdist = 0;
for(Iter i=begin; i!=end; ++i)
template<typename T, unsigned N>
BoundingSphere<T, N> operator|(const BoundingSphere<T, N> &bs1, const BoundingSphere<T, N> &bs2)
{
+ if(bs1.is_empty())
+ return bs2;
+ else if(bs2.is_empty())
+ return bs1;
+
LinAl::Vector<T, N> v = bs2.get_center()-bs1.get_center();
T d = v.norm();
if(d+bs2.get_radius()<bs1.get_radius())