pub struct Convex<S>(pub S);Expand description
A newtype that checks for intersections using xenocollide.
Use Convex to check for intersections between two convex shapes (possibly
with different types).
§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)
));Tuple Fields§
§0: STrait Implementations§
Source§impl<S> BoundingSphereRadius for Convex<S>where
S: BoundingSphereRadius,
impl<S> BoundingSphereRadius for Convex<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 Convex<S>where
S: Deserialize<'de>,
impl<'de, S> Deserialize<'de> for Convex<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<A, B, R> IntersectsAt<Convex<A>, Cartesian<2>, R> for Convex<B>where
A: SupportMapping<Cartesian<2>> + BoundingSphereRadius,
B: SupportMapping<Cartesian<2>> + BoundingSphereRadius,
R: Rotate<Cartesian<2>> + Rotation,
RotationMatrix<2>: From<R>,
impl<A, B, R> IntersectsAt<Convex<A>, Cartesian<2>, R> for Convex<B>where
A: SupportMapping<Cartesian<2>> + BoundingSphereRadius,
B: SupportMapping<Cartesian<2>> + BoundingSphereRadius,
R: Rotate<Cartesian<2>> + Rotation,
RotationMatrix<2>: From<R>,
Source§fn intersects_at(
&self,
other: &Convex<A>,
v_ij: &Cartesian<2>,
o_ij: &R,
) -> bool
fn intersects_at( &self, other: &Convex<A>, v_ij: &Cartesian<2>, 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<A, B, R> IntersectsAt<Convex<A>, Cartesian<3>, R> for Convex<B>where
A: SupportMapping<Cartesian<3>> + BoundingSphereRadius,
B: SupportMapping<Cartesian<3>> + BoundingSphereRadius,
R: Rotate<Cartesian<3>> + Rotation,
RotationMatrix<3>: From<R>,
impl<A, B, R> IntersectsAt<Convex<A>, Cartesian<3>, R> for Convex<B>where
A: SupportMapping<Cartesian<3>> + BoundingSphereRadius,
B: SupportMapping<Cartesian<3>> + BoundingSphereRadius,
R: Rotate<Cartesian<3>> + Rotation,
RotationMatrix<3>: From<R>,
Source§fn intersects_at(
&self,
other: &Convex<A>,
v_ij: &Cartesian<3>,
o_ij: &R,
) -> bool
fn intersects_at( &self, other: &Convex<A>, v_ij: &Cartesian<3>, 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<A, B, R> IntersectsAtGlobal<Convex<A>, Cartesian<2>, R> for Convex<B>where
A: SupportMapping<Cartesian<2>> + BoundingSphereRadius,
B: SupportMapping<Cartesian<2>> + BoundingSphereRadius,
R: Rotate<Cartesian<2>> + Rotation,
RotationMatrix<2>: From<R>,
impl<A, B, R> IntersectsAtGlobal<Convex<A>, Cartesian<2>, R> for Convex<B>where
A: SupportMapping<Cartesian<2>> + BoundingSphereRadius,
B: SupportMapping<Cartesian<2>> + BoundingSphereRadius,
R: Rotate<Cartesian<2>> + Rotation,
RotationMatrix<2>: From<R>,
Source§impl<A, B, R> IntersectsAtGlobal<Convex<A>, Cartesian<3>, R> for Convex<B>where
A: SupportMapping<Cartesian<3>> + BoundingSphereRadius,
B: SupportMapping<Cartesian<3>> + BoundingSphereRadius,
R: Rotate<Cartesian<3>> + Rotation,
RotationMatrix<3>: From<R>,
impl<A, B, R> IntersectsAtGlobal<Convex<A>, Cartesian<3>, R> for Convex<B>where
A: SupportMapping<Cartesian<3>> + BoundingSphereRadius,
B: SupportMapping<Cartesian<3>> + BoundingSphereRadius,
R: Rotate<Cartesian<3>> + Rotation,
RotationMatrix<3>: From<R>,
Source§impl<V, S> SupportMapping<V> for Convex<S>where
S: SupportMapping<V>,
impl<V, S> SupportMapping<V> for Convex<S>where
S: SupportMapping<V>,
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 Convex<S>
Auto Trait Implementations§
impl<S> Freeze for Convex<S>where
S: Freeze,
impl<S> RefUnwindSafe for Convex<S>where
S: RefUnwindSafe,
impl<S> Send for Convex<S>where
S: Send,
impl<S> Sync for Convex<S>where
S: Sync,
impl<S> Unpin for Convex<S>where
S: Unpin,
impl<S> UnsafeUnpin for Convex<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for Convex<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