# Physics needed to build a top down billiards game [duplicate]

Possible Duplicate:
How are these balls reflected after they hit each other?

I was wondering what sort of physics equations would I need in order to build a top down billiards game? I tried using Box2D (a 2D physics engine for games) but it has issues with objects going through other objects when the velocity is too fast. So I decided to do all the physics by scratch.

So, what would be all the physics I need to create a top down 2D billiards game?

Thanks!

-

## marked as duplicate by Mark Eichenlaub, David Z♦Aug 6 '11 at 0:17

Though this question is tagged collision, which was indeed covered by the earlier questions, collisions make up just a small part (and not the physically most interesting one) of billiard ball dynamics. Perhaps some other tags would fit better, I aimed my answer at those other aspects anyway. – leftaroundabout Aug 6 '11 at 1:25
Could you recommend any tags? I'd be happy to ad them. – Edgar Miranda Aug 6 '11 at 18:32

The most important thing is conservation of momentum to describe the collisions. This part is actually quite straightforward, but before you get to collisions you should model the motion of single balls.

Obviously, you will describe the balls classically and probably not at relativistic speeds (though that would be interesting...) so pretty much all you need is Newton $\mathbf{F}=m\cdot \mathbf{a}$ for the frictional forces. However, describing the balls as solid spheres, you don't just need directed forces but also torques to describe the rotation $\pmb{\omega}$. It changes as $$J\cdot\dot{\pmb{\omega}} = \pmb{\tau}$$ where the moment of inertia $J$ would, for a general rigid body, be a tensor but is for spherical objects just a number. The torque $\pmb{\tau}$ consists of

• The rolling friction, which occurs whenever a ball moves. It should be possible to model this simply by a multiple of the vector the ball would rotate about if it did properly roll, that is $$\pmb{\tau}_\mathrm{roll} = \eta_\mathrm{roll}\:\mathbf{e}_z\times \mathbf{v}$$ where $\mathbf{v}=\dot{\mathbf{r}}$ is assumed to always lie in the $xy$ plane, disregarding the possibility of balls jumping.
• The sliding friction, that is, the part of the friction that causes the balls to roll in the first place rather than just gliding over the surface like a curling stone. This actually originates as a directed force rather than a torque: if the ball could not rotate, if would just be the aforementioned $\mathbf{F}=m\cdot \mathbf{a}=m\cdot\ddot{\mathbf{r}}$. Such a "dry" sliding force has a pretty much constant strength but always points into the direction the surfaces slide against each other. $\mathbf{F}=m\mu\frac{\mathbf{v}_\mathrm{rel.slide}}{\|\mathbf{v}_\mathrm{rel.slide}\|}$ with some constant $\mu$ and $$\mathbf{v}_\mathrm{rel.slide} = \mathbf{v} - \mathbf{v}_\mathrm{ballbottom}$$ where ($R$ is the ball radius) $$\mathbf{v}_\mathrm{ballbottom} = \left(\begin{smallmatrix}\mathbf{e}_x\\\mathbf{e}_y\\\mathbf{e}_z\end{smallmatrix}\right)\left(\begin{smallmatrix}0&-1&0\\1&0&0\\0&0&0\end{smallmatrix}\right)\left(\begin{smallmatrix}\mathbf{e}_x\\\mathbf{e}_y\\\mathbf{e}_z\end{smallmatrix}\right)R\cdot\pmb{\omega}.$$
With a rotationable ball the same force also comes up as a torque because it's applied just to the low end of the ball. It is linked by the same linear (matrix) mapping, but with one additional contribution: the ball can also spin like a top. This does not directly interact with the movement but is neverthess important. $$\pmb{\tau}_\mathrm{slide} = R\cdot\left(\begin{smallmatrix}\mathbf{e}_x\\\mathbf{e}_y\\\mathbf{e}_z\end{smallmatrix}\right)\left(\begin{smallmatrix}0&-1&0\\1&0&0\\0&0&0\end{smallmatrix}\right)\left(\begin{smallmatrix}\mathbf{e}_x\\\mathbf{e}_y\\\mathbf{e}_z\end{smallmatrix}\right)\mathbf{F} + \mathbf{e}_z\:\eta_\text{spin}\omega_z.$$

That is enough to model, with some simple dynamic-system-simulator (Euler's method will easily do and is, in this case, actually better than the normally more sophisticated Runge-Kutta methods, because you want fine steps), the behaviour of a single ball on the table. There are then two types of collisions you need to take care for: with the cushions and with other balls. I shall not discuss the cushions here.

Collisions between balls are basically simple: quite good elastic scatterings, so pretty much only directed momentum is transferred, none of balls' own angular momenta and no energy is lost. To analyze such a collision, just enter the center of mass frame. At the collision point, both balls touch. The momentum (or equivanently velocity) of each of them is reflected off the plane going in between both points—that's all there is to it.
The difficulty when doing this in a computer simulation is just that you will not have a continuous motion but discrete steps. None of these will actually catch the point where the balls just touch, not unless you enforce it. Do do so, you need to check for collisions, and upon noticing one took place calculate, with a uniform motion, back to the point where the balls actually did touch. This is not really a physics problem, so I will not adress it here either.

-