Tuesday, July 23, 2019

2d - How do I calculate rotation caused by bounce friction?



Following on from my previous question: I have the ball quite realistically bouncing from surfaces it hits. Now I'd like to make it spin from the friction of the hit.


Showing this is simple enough: I rotate the ball by its angular velocity every tick and apply the same rotation when it's rendered.


When a ball hits a wall, I know that the speed of rotation is affected by...



  • the ball's initial speed when hitting the surface

  • the friction coefficients of the ball and surface (physical constants)

  • the angle of incidence (the angle between the ball's incoming velocity vector and the surface normal).


The angle of incidence is approximated by the dot product of the ball's impact and exit velocity vectors. (1 meaning high spin, -1 meaning no spin, and everything else relatively in between)


Multiplying all of the above together and making sure they were then transformed to the range 0 - 1, and multiplied by max rotation speed, the ball seemed to respond in rotation speed as expected. Except for one thing: It would always rotate clock-wise (because of positive values).





Is this a good method? Can you think of a simpler way?


If this method seems fine, what am I missing? How do I know when the ball should be rotating counter-clockwise?



Answer



Your method is nice, because it's very simple. One thing you might need is dependency on previous spin on the ball, which you do not take into account. The spinning ball represents rotational energy, so a realistic simulation would probably have to conserve it along with the other energies.


However, if the ball is not rotating upon impact, I can't imagine a situation in which it begins rotation against the direction of the incident angle. That is, "clockwise" or "counterclockwise" should be relative to whichever side of the normal the incident angle is.


I think simply multiplying the result by the original x-direction vector (+1 if traveling left to right, -1 if traveling right to left) should do it.


Edit: You can use the cross-product for this. Incident cross normal provides a vector in the Z direction only (if we are on the 2D x-y plane). Look at the z-element: if it is positive, the ball's approach should cause it to spin clockwise. If it is negative, the ball should spin counterclockwise.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...