pub struct Sphere {
pub c: Vector3,
pub r: f64,
}Fields§
§c: Vector3§r: f64Implementations§
Trait Implementations§
Source§impl Shape for Sphere
impl Shape for Sphere
Source§fn normal(&self, point: &Vector3) -> Vector3
fn normal(&self, point: &Vector3) -> Vector3
Returns the normal (normalized) of the sphere at a given point (that should be in the surface of the sphere).
Source§fn intersects(&self, line: &Line3) -> List<f64>
fn intersects(&self, line: &Line3) -> List<f64>
Returns the intersections of the sphere with a line. If the line doesn´t collide the sphere, it returns an empty list. If the line is tangent to the sphere, it returns a list with the single lambda value. If the line instersects the sphere, it returns a list with the two intersection lambdas. The lambda value is used to calculate the point of intersection with the line.calc_point(lambda).
Source§fn closest_intersection(&self, line: &Line3) -> Option<Intersection>
fn closest_intersection(&self, line: &Line3) -> Option<Intersection>
Returns the closest positive intersection of the sphere with a line. If the line doesn´t collide the sphere, it returns Option None. If the line instersects the sphere, it returns the closest positive intersection lambda The lambda value is used to calculate the point of intersection with the line.calc_point(lambda).