pub struct Capsule<const N: usize> {
pub radius: PositiveReal,
pub height: PositiveReal,
}Expand description
All points less than or equal to a distance r from a line segment of length h.
This line is oriented along the [0 0 ... 1] direction, and has extents +h/2,
-h/2 along that axis.
§Examples
Construction and basic methods:
use approxim::assert_relative_eq;
use hoomd_geometry::{BoundingSphereRadius, Volume, shape::Capsule};
use hoomd_vector::Cartesian;
use std::f64::consts::PI;
let capsule = Capsule::<2> {
radius: 1.0.try_into()?,
height: 8.0.try_into()?,
};
let bounding_radius = capsule.bounding_sphere_radius();
let volume = capsule.volume();
assert_eq!(bounding_radius.get(), 5.0);
assert_relative_eq!(volume, 16.0 + PI);Intersection test:
use hoomd_geometry::{Convex, IntersectsAt, shape::Capsule};
use hoomd_vector::{Angle, Cartesian, Rotation};
use std::f64::consts::PI;
let capsule = Capsule::<2> {
radius: 1.0.try_into()?,
height: 8.0.try_into()?,
};
assert!(capsule.intersects_at(
&capsule,
&[1.75, 0.0].into(),
&Angle::identity()
));
assert!(!capsule.intersects_at(
&capsule,
&[4.0, 2.0].into(),
&Angle::identity()
),);
assert!(capsule.intersects_at(
&capsule,
&[4.0, -2.0].into(),
&Angle::from(PI / 2.0)
));Fields§
§radius: PositiveRealRadius of points that are considered enclosed in the shape.
height: PositiveRealLength of the line segment.
Trait Implementations§
Source§impl<const N: usize> BoundingSphereRadius for Capsule<N>
impl<const N: usize> BoundingSphereRadius for Capsule<N>
Source§fn bounding_sphere_radius(&self) -> PositiveReal
fn bounding_sphere_radius(&self) -> PositiveReal
Get the bounding radius.
Source§impl<'de, const N: usize> Deserialize<'de> for Capsule<N>
impl<'de, const N: usize> Deserialize<'de> for Capsule<N>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<const N: usize, R> IntersectsAt<Capsule<N>, Cartesian<N>, R> for Capsule<N>
impl<const N: usize, R> IntersectsAt<Capsule<N>, Cartesian<N>, R> for Capsule<N>
Source§fn intersects_at(
&self,
other: &Capsule<N>,
v_ij: &Cartesian<N>,
o_ij: &R,
) -> bool
fn intersects_at( &self, other: &Capsule<N>, v_ij: &Cartesian<N>, o_ij: &R, ) -> bool
Test whether the set of points in one shape intersects with the set of another
(in the local frame). Read more
Source§fn approximate_separation_distance(
&self,
other: &S,
v_ij: &V,
o_ij: &R,
resolution: PositiveReal,
) -> f64where
V: InnerProduct,
fn approximate_separation_distance(
&self,
other: &S,
v_ij: &V,
o_ij: &R,
resolution: PositiveReal,
) -> f64where
V: InnerProduct,
Approximate the amount of overlap between two shapes. Read more
Source§impl<const N: usize> SupportMapping<Cartesian<N>> for Capsule<N>
impl<const N: usize> SupportMapping<Cartesian<N>> for Capsule<N>
Source§fn support_mapping(&self, n: &Cartesian<N>) -> Cartesian<N>
fn support_mapping(&self, n: &Cartesian<N>) -> Cartesian<N>
Return the furthest extent of a shape in the direction of
n.impl<const N: usize> StructuralPartialEq for Capsule<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Capsule<N>
impl<const N: usize> RefUnwindSafe for Capsule<N>
impl<const N: usize> Send for Capsule<N>
impl<const N: usize> Sync for Capsule<N>
impl<const N: usize> Unpin for Capsule<N>
impl<const N: usize> UnsafeUnpin for Capsule<N>
impl<const N: usize> UnwindSafe for Capsule<N>
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more