pub struct Capsule<const D: usize> {
pub half_height: f64,
pub radius: f64,
pub axis: usize,
}Expand description
D-dimensional capsule: a line segment of length 2 * half_height along
axis, swept by a sphere of radius.
In local space, the two hemisphere centers are at:
+half_height * e_axis-half_height * e_axis
where e_axis is the unit vector along the chosen axis.
Fields§
§half_height: f64Half the distance between hemisphere centers.
radius: f64Radius of the hemispherical caps (and the cylinder).
axis: usizeWhich coordinate axis the capsule is aligned to (0=X, 1=Y, 2=Z, …).
Implementations§
Source§impl<const D: usize> Capsule<D>
impl<const D: usize> Capsule<D>
Sourcepub fn new(half_height: f64, radius: f64, axis: usize) -> Self
pub fn new(half_height: f64, radius: f64, axis: usize) -> Self
Create a capsule along the given axis.
half_height is half the distance between hemisphere centers.
Total length = 2 * half_height + 2 * radius.
Sourcepub fn y_aligned(half_height: f64, radius: f64) -> Self
pub fn y_aligned(half_height: f64, radius: f64) -> Self
Create a Y-aligned capsule (the most common orientation).
Sourcepub fn total_length(&self) -> f64
pub fn total_length(&self) -> f64
Total length along the axis (including caps).
Trait Implementations§
Source§impl<const D: usize> Shape<D> for Capsule<D>
impl<const D: usize> Shape<D> for Capsule<D>
Source§fn support(&self, direction: &SVector<f64, D>) -> SVector<f64, D>
fn support(&self, direction: &SVector<f64, D>) -> SVector<f64, D>
Support function: pick the hemisphere center that dots highest with
the direction, then offset by radius * normalize(direction).
support(d) = sign(d[axis]) * half_height * e_axis + radius * normalize(d)
Source§fn bounding_sphere(&self) -> (Point<D>, f64)
fn bounding_sphere(&self) -> (Point<D>, f64)
impl<const D: usize> Copy for Capsule<D>
Auto Trait Implementations§
impl<const D: usize> Freeze for Capsule<D>
impl<const D: usize> RefUnwindSafe for Capsule<D>
impl<const D: usize> Send for Capsule<D>
impl<const D: usize> Sync for Capsule<D>
impl<const D: usize> Unpin for Capsule<D>
impl<const D: usize> UnsafeUnpin for Capsule<D>
impl<const D: usize> UnwindSafe for Capsule<D>
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
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.