Ver Fonte

Adding distanceToVec in sphere3d namespace

giagitom há 2 anos atrás
pai
commit
ac33b4a322
1 ficheiros alterados com 7 adições e 1 exclusões
  1. 7 1
      src/mol-math/geometry/primitives/sphere3d.ts

+ 7 - 1
src/mol-math/geometry/primitives/sphere3d.ts

@@ -277,6 +277,12 @@ namespace Sphere3D {
     export function distance(a: Sphere3D, b: Sphere3D) {
     export function distance(a: Sphere3D, b: Sphere3D) {
         return Vec3.distance(a.center, b.center) - a.radius + b.radius;
         return Vec3.distance(a.center, b.center) - a.radius + b.radius;
     }
     }
+
+    /** Get the distance of v from sphere. If negative, v is inside sphere */
+    export function distanceToVec(sphere: Sphere3D, v: Vec3): number {
+        const { center, radius } = sphere;
+        return Vec3.distance(v, center) - radius;
+    }
 }
 }
 
 
-export { Sphere3D };
+export { Sphere3D };