From 420e43d47dce0004f2f0c5a2c930081d94da9c61 Mon Sep 17 00:00:00 2001 From: Mathias Froehlich Date: Sat, 24 Nov 2012 09:54:21 +0100 Subject: [PATCH] sphere: Implement sphere inside sphere. --- simgear/math/SGSphere.hxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/simgear/math/SGSphere.hxx b/simgear/math/SGSphere.hxx index f46b7a0f..e4fcb096 100644 --- a/simgear/math/SGSphere.hxx +++ b/simgear/math/SGSphere.hxx @@ -72,6 +72,18 @@ public: void clear() { _radius = -1; } + /// Return true if this is inside sphere + bool inside(const SGSphere& sphere) const + { + if (empty()) + return false; + if (sphere.empty()) + return false; + + T dist = sphere.getRadius() - getRadius(); + return distSqr(getCenter(), sphere.getCenter()) <= dist*dist; + } + void expandBy(const SGVec3& v) { if (empty()) { -- 2.39.5