예제 #1
0
        public static MyVector IsIntersecting_SphereTriangle(Sphere sphere, Triangle triangle)
        {
            // Find the point on the triangle closest to the sphere's center
            MyVector retVal = triangle.GetClosestPointOnTriangle(sphere.Position);

            // Sphere and triangle intersect if the (squared) distance from sphere
            // center to point is less than the (squared) sphere radius
            MyVector v = retVal - sphere.Position;
            if (MyVector.Dot(v, v) <= sphere.Radius * sphere.Radius)
            {
                return retVal;
            }
            else
            {
                return null;
            }
        }