// Test for intersection between sphere and triangle
//
// Returns None if the inputs do not intersect, otherwise returns the
// point on the triangle closest to the sphere center.
Test for intersection between sphere and triangle
Returns None if the inputs do not intersect, otherwise returns the
point on the triangle closest to the sphere center.
Test for intersection between sphere and triangle Returns None if the inputs do not intersect otherwise returns the point on the triangle closest to the sphere center .
pub fn intersect_sphere_triangle(sphere: &Sphere3f,
                                 triangle: [Vec3f; 3]) -> Option<Vec3f> {
    // Find point P on triangle ABC closest to sphere center
    let p = triangle_closest_point_to_point(triangle, sphere.center);
    // Sphere and triangle intersect if the (squared) distance from
    // sphere center to point p is less than the (squared) sphere
    // radius
    let v = p - sphere.center;
    if v.magnitude_squared() <= sphere.radius_squared() {
        Some(p)
    }
    else {
        None
    }
}
pub fn intersect_sphere_triangle ( sphere : & Sphere3f , triangle : [ Vec3f ; 3 ] ) -> Option < Vec3f > { // Find point P on triangle ABC closest to sphere center let p = triangle_closest_point_to_point ( triangle , sphere . center ) ; // Sphere and triangle intersect if the (squared) distance from // sphere center to point p is less than the (squared) sphere // radius let v = p - sphere . center ; if v . magnitude_squared ( ) <= sphere . radius_squared ( ) { Some ( p ) } else { None } }
Test for intersection between sphere and triangle
Returns None if the inputs do not intersect, otherwise returns the
point on the triangle closest to the sphere center.
Test for intersection between sphere and triangle Returns None if the inputs do not intersect otherwise returns the point on the triangle closest to the sphere center .
sphere
&Sphere3f
triangle
[Vec3f; 3]