pub struct SweptSphere {
pub center_start: [f64; 3],
pub center_end: [f64; 3],
pub radius: f64,
}Expand description
A sphere swept along a straight line segment — effectively a capsule.
Fields§
§center_start: [f64; 3]World-space centre at the start of the sweep.
center_end: [f64; 3]World-space centre at the end of the sweep.
radius: f64Radius of the sphere.
Implementations§
Source§impl SweptSphere
impl SweptSphere
Sourcepub fn new(center_start: [f64; 3], center_end: [f64; 3], radius: f64) -> Self
pub fn new(center_start: [f64; 3], center_end: [f64; 3], radius: f64) -> Self
Create a new SweptSphere.
Sourcepub fn aabb(&self) -> ([f64; 3], [f64; 3])
pub fn aabb(&self) -> ([f64; 3], [f64; 3])
Compute a tight axis-aligned bounding box enclosing the entire sweep.
Sourcepub fn sweep_length(&self) -> f64
pub fn sweep_length(&self) -> f64
Length of the sweep path.
Sourcepub fn surface_area(&self) -> f64
pub fn surface_area(&self) -> f64
Surface area of the swept volume (capsule surface area).
Sourcepub fn ray_intersect(
&self,
ray_origin: [f64; 3],
ray_dir: [f64; 3],
) -> Option<f64>
pub fn ray_intersect( &self, ray_origin: [f64; 3], ray_dir: [f64; 3], ) -> Option<f64>
Ray vs swept sphere (capsule) intersection.
Returns the smallest non-negative t such that the ray
ray_origin + t * ray_dir touches the capsule surface, or None on
miss.
The capsule is the Minkowski sum of the line segment
[center_start, center_end] with a ball of radius.
Trait Implementations§
Source§impl Clone for SweptSphere
impl Clone for SweptSphere
Source§fn clone(&self) -> SweptSphere
fn clone(&self) -> SweptSphere
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SweptSphere
impl RefUnwindSafe for SweptSphere
impl Send for SweptSphere
impl Sync for SweptSphere
impl Unpin for SweptSphere
impl UnsafeUnpin for SweptSphere
impl UnwindSafe for SweptSphere
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.