aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2020-10-12 18:33:58 +0200
committerCrozet Sébastien <developer@crozet.re>2020-10-12 18:33:58 +0200
commitfaec3d5d46c88e2949179dd2789899e5cf26ed48 (patch)
treea47017788a0e7b7a99dd5a3f9a6ce64919b6c6b5 /src/dynamics
parentf8acf6a5e9d3ba537dac6502b0e0541236b418c5 (diff)
downloadrapier-faec3d5d46c88e2949179dd2789899e5cf26ed48.tar.gz
rapier-faec3d5d46c88e2949179dd2789899e5cf26ed48.tar.bz2
rapier-faec3d5d46c88e2949179dd2789899e5cf26ed48.zip
Start adding cylinders.
Diffstat (limited to 'src/dynamics')
-rw-r--r--src/dynamics/mass_properties_capsule.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/dynamics/mass_properties_capsule.rs b/src/dynamics/mass_properties_capsule.rs
index 5f08958..77ba96d 100644
--- a/src/dynamics/mass_properties_capsule.rs
+++ b/src/dynamics/mass_properties_capsule.rs
@@ -1,7 +1,7 @@
use crate::dynamics::MassProperties;
#[cfg(feature = "dim3")]
use crate::geometry::Capsule;
-use crate::math::{Point, PrincipalAngularInertia, Vector};
+use crate::math::{Point, PrincipalAngularInertia, Rotation, Vector};
impl MassProperties {
fn cylinder_y_volume_unit_inertia(
@@ -57,4 +57,16 @@ impl MassProperties {
)
}
}
+
+ #[cfg(feature = "dim3")]
+ pub(crate) fn from_cylinder(density: f32, half_height: f32, radius: f32) -> Self {
+ let (cyl_vol, cyl_unit_i) = Self::cylinder_y_volume_unit_inertia(half_height, radius);
+
+ Self::with_principal_inertia_frame(
+ Point::origin(),
+ cyl_vol * density,
+ cyl_unit_i * density,
+ Rotation::identity(),
+ )
+ }
}