Add sphere to sphere intersection test

This commit is contained in:
Jarrod Doyle 2024-10-06 10:55:56 +01:00
parent 1d32b3ef7b
commit 5fcf9db59c
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 6 additions and 0 deletions

View File

@ -49,6 +49,12 @@ public static class MathUtils
return d2 < r2;
}
public static bool Intersects(Sphere sphere, Sphere other)
{
var rsum = sphere.Radius + other.Radius;
return (sphere.Position - other.Position).Length() <= rsum;
}
public static float DistanceFromPlane(Plane plane, Vector3 point)
{
return Math.Abs(Vector3.Dot(plane.Normal, point) + plane.D) / plane.Normal.Length();