pub enum Shape {
Box {
half_extents: Vec3Fix,
},
Cylinder {
radius: Fix128,
half_height: Fix128,
},
Cone {
radius: Fix128,
half_height: Fix128,
},
Ellipsoid {
radii: Vec3Fix,
},
Wedge {
width: Fix128,
height: Fix128,
depth: Fix128,
},
Torus {
major_radius: Fix128,
minor_radius: Fix128,
},
}Expand description
A solid, by its dimensions.
Dimensions are lengths and must be positive; Shape::validate says whether
they are. The pose is not part of a shape: it is the body’s.
Variants§
Box
A box of the given half-extents along X, Y, Z.
Cylinder
A solid cylinder along Y.
Cone
A solid cone along Y, apex at +half_height, base at −half_height.
Fields
Ellipsoid
A solid ellipsoid with the given semi-axes.
Wedge
A triangular prism: an isosceles triangle in the XY plane (base width
at −height / 2, apex at +height / 2) extruded depth along Z.
Fields
Torus
A solid torus around Y.
Implementations§
Source§impl Shape
impl Shape
Sourcepub fn validate(&self) -> Result<(), ShapeError>
pub fn validate(&self) -> Result<(), ShapeError>
Whether every dimension is positive (and a torus has a hole).
Sourcepub fn volume(&self) -> Fix128
pub fn volume(&self) -> Fix128
Volume.
Meaningful for a shape that passes Self::validate and whose size is
representable; for an enormous one Fix128 wraps, which is why
PhysicsWorld::add_shaped_body(crate::solver::PhysicsWorld::add_shaped_body)
checks the magnitude first.
Sourcepub fn center_of_mass_offset(&self) -> Vec3Fix
pub fn center_of_mass_offset(&self) -> Vec3Fix
Offset of the centre of mass from the geometric centre, in the shape’s
local frame: zero for the shapes symmetric about their centre, and along
Y for the cone (−half_height / 2) and the wedge (−height / 6).
Sourcepub fn inertia_diagonal(&self, mass: Fix128) -> Vec3Fix
pub fn inertia_diagonal(&self, mass: Fix128) -> Vec3Fix
Diagonal of the inertia tensor about the centre of mass, for a given mass, in the shape’s local frame.
Sourcepub fn bounding_radius(&self) -> Fix128
pub fn bounding_radius(&self) -> Fix128
Radius of the smallest sphere about the centre of mass that encloses the solid.
Sourcepub fn mass_and_inertia(
&self,
density: Fix128,
) -> Result<(Fix128, Vec3Fix), ShapeError>
pub fn mass_and_inertia( &self, density: Fix128, ) -> Result<(Fix128, Vec3Fix), ShapeError>
The mass of this shape at density, with the principal inertia about its
centre of mass; refuses what cannot be a body.
§Errors
ShapeError::NonPositiveDensity, ShapeError::DegenerateShape (from
Self::validate), and ShapeError::MassNotRepresentable when the mass
times the square of the longest dimension — the scale of the inertia — does
not fit comfortably in Fix128, or the arithmetic came out non-positive
anyway.
Trait Implementations§
impl Copy for Shape
impl Eq for Shape
impl StructuralPartialEq for Shape
Auto Trait Implementations§
impl Freeze for Shape
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnsafeUnpin for Shape
impl UnwindSafe for Shape
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