From 139888376913d0509f7f26e9ea2dba2fb6182f1c Mon Sep 17 00:00:00 2001 From: siddhant <237064492+Siddhant52@users.noreply.github.com> Date: Sat, 20 Jun 2026 23:32:03 +0530 Subject: [PATCH] fix: derive circular motion velocity from centripetal force instead of forcing constant speed --- simulations/CircularMotion.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/simulations/CircularMotion.jsx b/simulations/CircularMotion.jsx index bbf7a43b..bafd91dd 100644 --- a/simulations/CircularMotion.jsx +++ b/simulations/CircularMotion.jsx @@ -148,9 +148,12 @@ export default function CircularMotion() { bodyRef.current.applyForce(centripetalForce); } - // Enforce constant speed - if (bodyRef.current.state.velocity.mag() > 0) { - bodyRef.current.state.velocity.setMag(speed); + // Gently correct for numerical drift (instead of forcing speed every frame) + const currentSpeed = bodyRef.current.state.velocity.mag(); + if (currentSpeed > 0) { + const correctionFactor = + 1 + ((speed - currentSpeed) / currentSpeed) * 0.05; + bodyRef.current.state.velocity.mult(correctionFactor); } // Step physics