How can I realistically simulate the course of golf using the physics of the Bullet? (Including demo version)

Background

I play with a mini-toy using tr.js and ammo.js, the Bullet Physics conversion library, but I am having some problems making the ball realistic.

(I put the demo at penguinspuzzle.appspot.com/minigolf.html if you want to see how this works in practice.)

Question

What good algorithm gives a more realistic mini-golf ball movement?

What i tried

Ammo.js has options for friction, linear damping, and rotational damping.

When the balls roll, the friction setting does not have much effect.

I am currently using

body.setRestitution(0.8); body.setFriction(1); body.setDamping(0.2,0.1); // linear damping, rotational damping 

Problems

At high linear damping values, the ball seems to slow down too quickly.

At lower values, it seems to take age to finally stop.

When the ball is in the air, it seems unreasonable to apply linear damping at all.

Analysis

I think the problem may be linear damping in ammo.js, which leads to exponential slowdown.

I tried:

  • Golf video recording
  • Measuring the location of the ball in each frame
  • Determining the location and speed of the ball against time

The results are shown below. It seems to me that the velocity profile is much closer to linear than exponential.

Any suggestions on an algorithm to get ammo.js more realistic?

Golf analysis

+6
source share
1 answer

I noticed that you use "regular" friction on a spherical object. In physics, there is a separate concept of "rolling friction" for round objects. I do not know if Bullet Physics has provided such a concept in its API. If so, try replacing this with sliding friction:

 body.setFriction(1); 
+1
source

Source: https://habr.com/ru/post/952769/


All Articles