From: Mathias Froehlich Date: Sat, 24 Nov 2012 08:54:21 +0000 (+0100) Subject: sphere: Implement sphere inside sphere. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=420e43d47dce0004f2f0c5a2c930081d94da9c61;p=simgear.git sphere: Implement sphere inside sphere. --- 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()) {