Background
I am playing with making a minigolf game using three.js and the ammo.js conversion of the Bullet Physics library but I am having some trouble getting the ball to move realistically.
(I've put a demo at penguinspuzzle.appspot.com/minigolf.html if you want to have a look at how this works in practice.)
Question
What is a good algorithm to give more realistic motion of a minigolf ball?
What I've tried
In ammo.js there are options for friction, linear damping, and rotational damping.
As the ball rolls, the friction setting does not seem to have much effect.
I'm currently using
body.setRestitution(0.8);
body.setFriction(1);
body.setDamping(0.2,0.1); // linear damping, rotational damping
Problems
With high values of linear damping the ball seems to decelerate too fast.
With lower values it seems to take ages to finally stop.
When the ball is in the air it seems unreasonable to be applying linear damping at all.
Analysis
I think the problem may be the linear damping in ammo.js which causes an exponential slow down.
I tried:
- Recording a video of a golf stroke
- Measuring the location of the ball in each frame
- Plotting the location and speed of the ball against time
The results are shown below. It looks to me like the velocity profile is much closer to being linear than exponential.
Any suggestions for an algorithm to get ammo.js to be more realistic?