X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmath%2FSGSphere.hxx;h=e4fcb096a7e576a53ca1cfe69d867cf6b695a542;hb=584ee1364f25e5c3795f9ff4633a792cba39bfc7;hp=f46b7a0ffab4421d8b620104da2a9b101ab0834d;hpb=423eba373389684061fc0a8c7b78292f10011ed7;p=simgear.git 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()) {