]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGSphere.hxx
math: Add integer valued vector types.
[simgear.git] / simgear / math / SGSphere.hxx
index f46b7a0ffab4421d8b620104da2a9b101ab0834d..e4fcb096a7e576a53ca1cfe69d867cf6b695a542 100644 (file)
@@ -72,6 +72,18 @@ public:
   void clear()
   { _radius = -1; }
 
+  /// Return true if this is inside sphere
+  bool inside(const SGSphere<T>& 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<T>& v)
   {
     if (empty()) {