Bouncing ball with friction.

I am trying to write freefem code (same language as c++) for a bouncing ball, but I am not able to notice the result of friction force. At each time the rigid ball hits the rigid ground, the horizontal velocity must be decreased. While I am trying the velocity is not decreased, it is still bouncing for a fixed height.

Any hint please, I will be thankful for any indication that help me proceed in writing the code.

for(n=0;n<200;n++){

ax = 0;
ay = (Fgy+Fry+Fby+Fhy)/M;  // Forces that acts on the ball in the y direction and M is the mass of the ball

V01=V01+dt*ax;
V02=V02+dt*ay;

if(G02<4){
G02=4;
V02=V02*(0.95);
}

if(G02>33.){
G02=33.;
V02=V02*(0.95);
}

if(G01>46.){
G01=46.;
V01=V01*(0.95);
}

if(G01<4.){
G01=4.;
V01=V01*(0.95);
}

G01=G01+dt*V01;
G02=G02+dt*V02;

...plot...

}


$(G01,G02)$ is the coordinates of center of mass of the ball and $(V01,V02)$ the velocity vector of the ball ,$ax$ and $ay$ are the 2 components of the acceleration. The domain is $[0,50]\times [0,37]$ and the radius of the ball is $r=4$.

$0.95$ is the value of restitution.

• This sounds like it belongs in physics.stackexchange.com Commented Jun 28, 2018 at 17:47
• Friction will turn convert the lateral motion of the ball into rotational motion. Soon enough the ball has the rotational speed that matches the lateral motion and it will not slow down any more. But again, this is a physics issue and not math. Commented Jun 28, 2018 at 17:50
• then definitely something is wrong with your code. Commented Jun 28, 2018 at 18:06
• Yes, multiplying the vertical velocity by a constant less than $1$ is a reasonable model. You need to understand why that is not working for you. Commented Jun 28, 2018 at 18:25
• You need to reverse the sign of the velocity components after the bounce. Like V02= -V02*(0.95);. Also you never modify the rotational speed, which is affected by friction. Commented Jun 28, 2018 at 22:19

Consider the general planar case of a ball impacting the ground with friction $\mu$. The general motion of the ball is described by the velocity components $\dot{x}$, $\dot{y}$ and $\dot{\theta}$ just before the impact.

At the moment of impact, two impulses act on the ball $N$ and $F$ altering the motion of the ball afterward by

\begin{aligned} \Delta \dot{x} & = \frac{1}{m} F \\ \Delta \dot{y} & = \frac{1}{m} N \\ \Delta \dot{\theta} & = \frac{1}{I} r F \end{aligned}

where $m$ is the mass and $I$ the mass moment of inertia for the ball about the center of mass.

Now consider what must happen after the impact. The vertical velocity should be a fraction of the impacting velocity

$$\dot{y} + \Delta \dot{y} = -\epsilon\, \dot{y}$$

where $\epsilon$ is the coefficient of restitution. Use 0 for plastic impact, and 1 for purely elastic.

In the horizontal direction, things get more interesting. Consider first the situation of high friction where the surface of the ball acquires the speed of the ground (zero). The surface velocity is $v = \dot{x} + r\,\dot{\theta}$ or

$$(\dot{x} + r\,\dot{\theta}) + (\Delta\dot{x} + r\,\Delta\dot{\theta}) = 0$$

Use these two equations to find the impulses

\begin{aligned} N & = -(1+\epsilon)\, m\, \dot{y} \\ F & = - \frac{1}{\frac{1}{m} + \frac{r^2}{I}} (\dot{x} + r\,\dot{\theta}) \end{aligned}

Now you check if the frictional impulse is more than traction.

$$F = \begin{cases} -\mu |N| {\rm sign}(\dot{x} + r\,\dot{\theta}) & |F| > \mu |N| \\ \mbox{unmodified} & |F| \le \mu |N| \end{cases}$$

Finally, apply the impluses with

\begin{aligned} \Delta \dot{x} & = \frac{1}{m} F \\ \Delta \dot{y} & = \frac{1}{m} N \\ \Delta \dot{\theta} & = \frac{1}{I} r F \end{aligned}

and continue the simulation.

• excuse my ignorance, but what does the term "sign" mean in the line: −μ|N|sign(x˙+rθ˙) Commented Dec 29, 2020 at 23:08

I don't see any part of your code that attempts to apply friction (you've implemented a coefficient of restitution, which is also a dissipative phenomenon but is in fact rather unrelated to friction.)

A very simple model of frictional impact would be a Coulomb law.

1) You resolved the impact by applying an impulse (change in momentum) in the direction of the contact normal $\hat{n}$. Compute the magnitude of the normal impulse: $J_n = p^+\cdot n - p^- \cdot n,$ where $p^-$ and $p^+$ are the momentum of the ball before and after the impact. Notice that $J_n$ is always positive.

2) Compute the tangential momentum $p^{+}_{t} = p^+ - (p^+\cdot \hat{n})\hat n.$ (You could also use the pre-impact momentum; the value would be the same.)

3) Compute the magnitude of the friction impulse using Coulomb's law: $$J_t = \min(\|p_t^+\|, \mu J_n)$$ where $\mu$ is the coefficient of friction. The first term in the minimum is there to ensure that your frictional impulse at most stops, but never reverses, the tangential momentum of the ball. The second term enforces the friction cone constraint---the harder the ball hits the wall, the more friction is allowed.

4) Apply the friction impulse: add $-J_t \frac{p_t^+}{\|p_t^+\|}$ to the ball's post-impact momentum.

This scheme is extremely simplistic and will not work if you have multiple simultaneous collisions, if the friction impulses themselves cause new collisions, etc. But it is hopefully a start.