aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics
diff options
context:
space:
mode:
authorSébastien Crozet <sebcrozet@dimforge.com>2024-04-28 15:47:49 +0200
committerSébastien Crozet <sebastien@crozet.re>2024-04-30 23:10:46 +0200
commit5867d2e78d9cdd6b495d22346c4f59ac25ff6d1b (patch)
treee8856aa4910713fdf3386f9cddbcad5b3e1f4339 /src/dynamics
parent2678b08bf4a4884b90c23826395a00cb1f67abe7 (diff)
downloadrapier-5867d2e78d9cdd6b495d22346c4f59ac25ff6d1b.tar.gz
rapier-5867d2e78d9cdd6b495d22346c4f59ac25ff6d1b.tar.bz2
rapier-5867d2e78d9cdd6b495d22346c4f59ac25ff6d1b.zip
fix: include the 0.5 factor in pseudo (mass-normalized) kinetic energy calculation
Diffstat (limited to 'src/dynamics')
-rw-r--r--src/dynamics/rigid_body_components.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/dynamics/rigid_body_components.rs b/src/dynamics/rigid_body_components.rs
index c03233d..f5698a4 100644
--- a/src/dynamics/rigid_body_components.rs
+++ b/src/dynamics/rigid_body_components.rs
@@ -571,10 +571,11 @@ impl RigidBodyVelocity {
/// The approximate kinetic energy of this rigid-body.
///
/// This approximation does not take the rigid-body's mass and angular inertia
- /// into account.
+ /// into account. Some physics engines call this the "mass-normalized kinetic
+ /// energy".
#[must_use]
pub fn pseudo_kinetic_energy(&self) -> Real {
- self.linvel.norm_squared() + self.angvel.gdot(self.angvel)
+ 0.5 * (self.linvel.norm_squared() + self.angvel.gdot(self.angvel))
}
/// Returns the update velocities after applying the given damping.