Computer Science Canada

Help needed regarding a billiards game

Author:  A.J [ Mon Apr 07, 2008 7:44 pm ]
Post subject:  Help needed regarding a billiards game

All I have right now are the balls moving around at random positions and velocities and hitting each other or sinking if they reach the corner/side pockets.
I need to add friction to the balls so that they don't move forever........
I need help regarding what I should do to the horizontal/vertical velocity each time I update the balls information.....
and if anyone could help me make the balls 3-D (or make a tutorial on making 3d engines/graphice) I'll really appreciate it Very Happy

thanks,
A.J

Author:  Saad [ Mon Apr 07, 2008 9:13 pm ]
Post subject:  Re: Help needed regarding a billiards game

All you need is newtons second law, F = ma, now the only force on the ball is the force of friction.

Therefore u Fn = ma (Where u is the coefficient of friction)
Since its a flat table, Fn is the same as its weight
umg = ma (g being the gravity)
ug = a

Therefore the magnitude of the acceleration of the friction force is u * g, now take a normal vector of your current velocity and multiply that by -1 since friction is in the opposite direction and multiply that by the magnitude of the acceleration of friction

Some pseudo code

code:
var V := CurrentVelocityVector
var accelerationMagnitude := u * g %% (Where u is the coefficient of friction and g is the gravity on earth)
var normalVelocityVector := (V / magnitude (V))
var accelerationVector := (normalVecloityVector * -1) * accelerationMagnitude
CurrentVelocityVector := CurrentVelocityVector + accelerationVector * timeStep


Play around with the u value to get it to apply the right amount of friction

As for 3D, look up 3d projection onto a 2D screen

Author:  A.J [ Mon Apr 07, 2008 9:45 pm ]
Post subject:  Re: Help needed regarding a billiards game

thx saad, I owe u Wink


: