aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics/mass_properties_capsule.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2021-01-29 14:42:32 +0100
committerGitHub <noreply@github.com>2021-01-29 14:42:32 +0100
commit7ca46f38cde6cf8bf8bf41ea6067ae5bc938205c (patch)
tree3781b9d7c92a6a8111573ba4cae1c5d41435950e /src/dynamics/mass_properties_capsule.rs
parente6fc8f67faf3e37afe38d683cbd930d457f289be (diff)
parent825f33efaec4ce6a8903751e836a0ea9c466ff92 (diff)
downloadrapier-7ca46f38cde6cf8bf8bf41ea6067ae5bc938205c.tar.gz
rapier-7ca46f38cde6cf8bf8bf41ea6067ae5bc938205c.tar.bz2
rapier-7ca46f38cde6cf8bf8bf41ea6067ae5bc938205c.zip
Merge pull request #79 from dimforge/split_geom
Move most of the geometric code to another crate.
Diffstat (limited to 'src/dynamics/mass_properties_capsule.rs')
-rw-r--r--src/dynamics/mass_properties_capsule.rs39
1 files changed, 0 insertions, 39 deletions
diff --git a/src/dynamics/mass_properties_capsule.rs b/src/dynamics/mass_properties_capsule.rs
deleted file mode 100644
index 3b1b214..0000000
--- a/src/dynamics/mass_properties_capsule.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-use crate::dynamics::MassProperties;
-#[cfg(feature = "dim3")]
-use crate::geometry::Capsule;
-use crate::math::Point;
-
-impl MassProperties {
- pub(crate) fn from_capsule(density: f32, a: Point<f32>, b: Point<f32>, radius: f32) -> Self {
- let half_height = (b - a).norm() / 2.0;
- let (cyl_vol, cyl_unit_i) = Self::cylinder_y_volume_unit_inertia(half_height, radius);
- let (ball_vol, ball_unit_i) = Self::ball_volume_unit_angular_inertia(radius);
- let cap_vol = cyl_vol + ball_vol;
- let cap_mass = cap_vol * density;
- let mut cap_unit_i = cyl_unit_i + ball_unit_i;
- let local_com = na::center(&a, &b);
-
- #[cfg(feature = "dim2")]
- {
- let h = half_height * 2.0;
- let extra = h * h * 0.5 + h * radius * 3.0 / 8.0;
- cap_unit_i += extra;
- Self::new(local_com, cap_mass, cap_unit_i * cap_mass)
- }
-
- #[cfg(feature = "dim3")]
- {
- let h = half_height * 2.0;
- let extra = h * h * 0.5 + h * radius * 3.0 / 8.0;
- cap_unit_i.x += extra;
- cap_unit_i.z += extra;
- let local_frame = Capsule::new(a, b, radius).rotation_wrt_y();
- Self::with_principal_inertia_frame(
- local_com,
- cap_mass,
- cap_unit_i * cap_mass,
- local_frame,
- )
- }
- }
-}