Skip to main content

Cylinder

Struct Cylinder 

Source
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: PositiveReal

Radius of the Cylinder

§height: PositiveReal

Height of the Cylinder

Implementations§

Source§

impl Cylinder

Source

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 Clone for Cylinder

Source§

fn clone(&self) -> Cylinder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cylinder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Cylinder

Source§

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 PartialEq for Cylinder

Source§

fn eq(&self, other: &Cylinder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Cylinder

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Volume for Cylinder

Source§

fn volume(&self) -> f64

The N-hypervolume of a geometry.
Source§

impl StructuralPartialEq for Cylinder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,