pub struct Cylinder { /* private fields */ }Expand description
A cylinder shape centered at the origin, aligned along the Y-axis.
A cylinder is a three-dimensional shape with a circular cross-section. It’s commonly used in physics engines for representing pillars, pipes, wheels, and other cylindrical objects.
The cylinder is centered at the origin (0, 0, 0) with its axis aligned to the Y-axis. It extends from -half_height to +half_height along the Y-axis.
§Examples
use phys_geom::shape::Cylinder;
// Create a cylinder with height 3.0 and radius 0.8
let cylinder = Cylinder::new(1.5, 0.8);
assert_eq!(cylinder.height(), 3.0);
assert_eq!(cylinder.radius(), 0.8);§Dimensions
half_height: Half the height of the cylinderradius: Radius of the circular cross-section- Total height =
2 * half_height
Implementations§
Source§impl Cylinder
impl Cylinder
Sourcepub fn new(half_height: Real, radius: Real) -> Self
pub fn new(half_height: Real, radius: Real) -> Self
Creates a new cylinder with the given dimensions.
§Arguments
half_height- Half the height of the cylinder (must be positive)radius- The radius of the cylinder (must be positive)
§Returns
A new Cylinder instance.
§Panics
Panics if half_height or radius is not positive.
§Examples
use phys_geom::shape::Cylinder;
// Create a cylinder with total height 4.0 and radius 1.0
let cylinder = Cylinder::new(2.0, 1.0);
assert_eq!(cylinder.height(), 4.0);
assert_eq!(cylinder.radius(), 1.0);Sourcepub fn half_height(&self) -> Real
pub fn half_height(&self) -> Real
Trait Implementations§
Source§impl ComputeAabb3 for Cylinder
impl ComputeAabb3 for Cylinder
Source§fn compute_aabb(&self) -> Aabb3
fn compute_aabb(&self) -> Aabb3
Compute the AABB in local space.
Source§impl ComputeVolume for Cylinder
impl ComputeVolume for Cylinder
Source§fn compute_volume(&self) -> Real
fn compute_volume(&self) -> Real
Computes the volume of this shape. Read more
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Cylinder
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 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
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.