Original Post
🔒 Locked
damped pendulum
Advertisement
Whoops, I misread that.
vel -= 9.8*Math.sin(theta)*dt;
vel *= exp(-b*dt);
theta += vel*dt/RADIUS;
That's a traditional dampening factor for oscillations.
As you keep calling this function, that exp(-b*dt) term will keep multiplying itself. After n iterations, the factor becomes exp(-b*dt*n). As n increases to infinity, -b*dt*n approaches negative infinity, and that means exp(-b*dt*n) approaches 0.
So calling vel *= exp(-b*dt) repeatedly reduces the velocity to 0 over time. You control how fast by increasing b.
vel -= 9.8*Math.sin(theta)*dt;
vel *= exp(-b*dt);
theta += vel*dt/RADIUS;
That's a traditional dampening factor for oscillations.
As you keep calling this function, that exp(-b*dt) term will keep multiplying itself. After n iterations, the factor becomes exp(-b*dt*n). As n increases to infinity, -b*dt*n approaches negative infinity, and that means exp(-b*dt*n) approaches 0.
So calling vel *= exp(-b*dt) repeatedly reduces the velocity to 0 over time. You control how fast by increasing b.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement