aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics/mass_properties.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2020-11-03 12:37:27 +0100
committerGitHub <noreply@github.com>2020-11-03 12:37:27 +0100
commit0cc850dc505a4034103d229fdce22f9ec7bc410a (patch)
tree6aa4a805092e5f92ad2d4b25fcc5370608c8e9da /src/dynamics/mass_properties.rs
parent704496d9889d2037d6e5e479d398c78bf3a83f75 (diff)
parentbd6c0cb26c560efb9ba31d7151bbf657cf25a738 (diff)
downloadrapier-0cc850dc505a4034103d229fdce22f9ec7bc410a.tar.gz
rapier-0cc850dc505a4034103d229fdce22f9ec7bc410a.tar.bz2
rapier-0cc850dc505a4034103d229fdce22f9ec7bc410a.zip
Merge pull request #52 from dimforge/set_mass
Add the ability to set the mass and mass properties of the rigid-body built with the RigidBodyBuilder
Diffstat (limited to 'src/dynamics/mass_properties.rs')
-rw-r--r--src/dynamics/mass_properties.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/dynamics/mass_properties.rs b/src/dynamics/mass_properties.rs
index d64839c..73e9b0d 100644
--- a/src/dynamics/mass_properties.rs
+++ b/src/dynamics/mass_properties.rs
@@ -25,8 +25,11 @@ pub struct MassProperties {
}
impl MassProperties {
+ /// Initializes the mass properties with the given center-of-mass, mass, and angular inertia.
+ ///
+ /// The center-of-mass is specified in the local-space of the rigid-body.
#[cfg(feature = "dim2")]
- pub(crate) fn new(local_com: Point<f32>, mass: f32, principal_inertia: f32) -> Self {
+ pub fn new(local_com: Point<f32>, mass: f32, principal_inertia: f32) -> Self {
let inv_mass = utils::inv(mass);
let inv_principal_inertia_sqrt = utils::inv(principal_inertia.sqrt());
Self {
@@ -36,13 +39,23 @@ impl MassProperties {
}
}
+ /// Initializes the mass properties from the given center-of-mass, mass, and principal angular inertia.
+ ///
+ /// The center-of-mass is specified in the local-space of the rigid-body.
+ /// The principal angular inertia are the angular inertia along the coordinate axes in the local-space
+ /// of the rigid-body.
#[cfg(feature = "dim3")]
- pub(crate) fn new(local_com: Point<f32>, mass: f32, principal_inertia: AngVector<f32>) -> Self {
+ pub fn new(local_com: Point<f32>, mass: f32, principal_inertia: AngVector<f32>) -> Self {
Self::with_principal_inertia_frame(local_com, mass, principal_inertia, Rotation::identity())
}
+ /// Initializes the mass properties from the given center-of-mass, mass, and principal angular inertia.
+ ///
+ /// The center-of-mass is specified in the local-space of the rigid-body.
+ /// The principal angular inertia are the angular inertia along the coordinate axes defined by
+ /// the `principal_inertia_local_frame` expressed in the local-space of the rigid-body.
#[cfg(feature = "dim3")]
- pub(crate) fn with_principal_inertia_frame(
+ pub fn with_principal_inertia_frame(
local_com: Point<f32>,
mass: f32,
principal_inertia: AngVector<f32>,