pub struct Sphero<S> {
pub shape: S,
pub rounding_radius: PositiveReal,
}Expand description
Round a shape with a given radius.
Sphero modifies a given shape by sweeping it with a hypersphere of the
given radius. The resulting Sphero<S> type is a shape itself. If S
implements crate::SupportMapping, then Sphero<S> can be used in
IntersectsAt tests with other convex shapes. See
the full list of implementations below to see what other traits Sphero<S>
implements for a given S.
§Example
Test if a circle overlaps with a rounded rectangle:
use hoomd_geometry::{
Convex, IntersectsAt,
shape::{Circle, Rectangle, Sphero},
};
use hoomd_vector::{Angle, Cartesian};
use std::f64::consts::PI;
let circle = Convex(Circle {
radius: 0.5.try_into()?,
});
let rectangle = Rectangle {
edge_lengths: [3.0.try_into()?, 2.0.try_into()?],
};
let rounded_rectangle = Convex(Sphero {
shape: rectangle,
rounding_radius: 0.5.try_into()?,
});
assert!(rounded_rectangle.intersects_at(
&circle,
&[2.4, 0.0].into(),
&Angle::default()
));
assert!(!rounded_rectangle.intersects_at(
&circle,
&[0.0, 2.4].into(),
&Angle::default()
));
assert!(circle.intersects_at(
&rounded_rectangle,
&[0.0, 2.4].into(),
&Angle::from(PI / 2.0)
));Fields§
§shape: SThe shape to round.
rounding_radius: PositiveRealThe radius of the rounding hypersphere.
Trait Implementations§
Source§impl<S> BoundingSphereRadius for Sphero<S>where
S: BoundingSphereRadius,
impl<S> BoundingSphereRadius for Sphero<S>where
S: BoundingSphereRadius,
Source§fn bounding_sphere_radius(&self) -> PositiveReal
fn bounding_sphere_radius(&self) -> PositiveReal
Get the bounding radius.
Source§impl<'de, S> Deserialize<'de> for Sphero<S>where
S: Deserialize<'de>,
impl<'de, S> Deserialize<'de> for Sphero<S>where
S: Deserialize<'de>,
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<S, V> SupportMapping<V> for Sphero<S>where
S: SupportMapping<V>,
V: InnerProduct,
impl<S, V> SupportMapping<V> for Sphero<S>where
S: SupportMapping<V>,
V: InnerProduct,
Source§fn support_mapping(&self, n: &V) -> V
fn support_mapping(&self, n: &V) -> V
Return the furthest extent of a shape in the direction of
n.impl<S> StructuralPartialEq for Sphero<S>
Auto Trait Implementations§
impl<S> Freeze for Sphero<S>where
S: Freeze,
impl<S> RefUnwindSafe for Sphero<S>where
S: RefUnwindSafe,
impl<S> Send for Sphero<S>where
S: Send,
impl<S> Sync for Sphero<S>where
S: Sync,
impl<S> Unpin for Sphero<S>where
S: Unpin,
impl<S> UnsafeUnpin for Sphero<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for Sphero<S>where
S: UnwindSafe,
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