pub struct Cylinder {
pub radius: PositiveReal,
pub height: PositiveReal,
}Expand description
A circle with normal [0 0 1] swept by h/2 in the +z and -z directions.
§Example
Cylinder implements the Volume trait, which is equivalent to
$\pi r^2 h$.
use hoomd_geometry::{Volume, shape::Cylinder};
use std::f64::consts::PI;
let cyl = Cylinder {
radius: 2.0.try_into()?,
height: 3.0.try_into()?,
};
assert_eq!(cyl.volume(), PI * (2.0 * 2.0) * 3.0);Fields§
§radius: PositiveRealRadius of the Cylinder
height: PositiveRealHeight of the Cylinder
Implementations§
Source§impl Cylinder
impl Cylinder
Sourcepub fn intersects_at_infinite(
&self,
other: &Self,
v_ij: &Cartesian<3>,
o_ij: &Versor,
) -> bool
pub fn intersects_at_infinite( &self, other: &Self, v_ij: &Cartesian<3>, o_ij: &Versor, ) -> bool
Determine whether two cylinders would intersect if they both had infinite length.
This implementation is based on Collision detection of cylindrical rigid bodies for motion planning, and provides a useful alternative to bounding sphere-based checks when the underlying bodies are highly elongated.
§Example
This example is based on the scenario of two highly anisotropic shapes, whose bounding spheres have a large amount of volume relative to a tighter fitting bounding shape. Note that the effective volume checked for the infinite bounding cylinder is actually the intersection of that cylinder and the ball queried in the neighbor list, so it is guaranteed to be finite.
// Two parallel cylinders that wrap a dipyramid of height:width ratio 5:1.
let c1 = Cylinder {
radius: 1.0.try_into().unwrap(),
height: 10.0.try_into().unwrap(),
};
let c2 = Cylinder {
radius: 1.0.try_into().unwrap(),
height: 10.0.try_into().unwrap(),
};
let o_ij = Versor::default();
// Case 1: Bounding spheres would intersect, but the bounding cylinders do not.
let v_ij_no_intersect = Cartesian::from([2.1, 0.0, 0.0]);
assert!(!c1.intersects_at_infinite(&c2, &v_ij_no_intersect, &o_ij));
// Case 2: Infinite cylinders intersect, meaning we need to further check the
// underlying shapes for collision.
let v_ij_intersect = Cartesian::from([1.9, 0.0, 0.0]);
assert!(c1.intersects_at_infinite(&c2, &v_ij_intersect, &o_ij));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cylinder
impl<'de> Deserialize<'de> for Cylinder
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>,
impl StructuralPartialEq for Cylinder
Auto Trait Implementations§
impl Freeze for Cylinder
impl RefUnwindSafe for Cylinder
impl Send for Cylinder
impl Sync for Cylinder
impl Unpin for Cylinder
impl UnsafeUnpin for Cylinder
impl UnwindSafe for Cylinder
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<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>
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>
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