pub struct Sphere {
pub center: Vec3,
pub radius: Real,
}Expand description
A sphere in 3D space.
Fields§
§center: Vec3Center of the sphere.
radius: RealRadius of the sphere.
Implementations§
Source§impl Sphere
impl Sphere
Sourcepub fn contains_point(&self, point: &Vec3) -> bool
pub fn contains_point(&self, point: &Vec3) -> bool
Test if point is inside or on the surface of the sphere.
Sourcepub fn overlaps_sphere(&self, other: &Sphere) -> bool
pub fn overlaps_sphere(&self, other: &Sphere) -> bool
Test if this sphere overlaps another sphere.
Sourcepub fn overlaps_aabb(&self, aabb: &Aabb) -> bool
pub fn overlaps_aabb(&self, aabb: &Aabb) -> bool
Test if this sphere overlaps an AABB.
Sourcepub fn ray_intersect(&self, ray: &Ray) -> Option<Real>
pub fn ray_intersect(&self, ray: &Ray) -> Option<Real>
Ray–sphere intersection. Returns the entry t-value or None.
Sourcepub fn surface_area(&self) -> Real
pub fn surface_area(&self) -> Real
Surface area of the sphere.
Sourcepub fn bounding_sphere(points: &[Vec3]) -> Option<Sphere>
pub fn bounding_sphere(points: &[Vec3]) -> Option<Sphere>
Minimum enclosing sphere of a set of points (Ritter’s algorithm).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sphere
impl RefUnwindSafe for Sphere
impl Send for Sphere
impl Sync for Sphere
impl Unpin for Sphere
impl UnsafeUnpin for Sphere
impl UnwindSafe for Sphere
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.