Hi, i have created a 2d snooker game, which implements collision detection, but i am not sure how to implement the physical simulation of the balls, i.e. the formulas needed to calculated the force, acceleration, FRICTION, etc. At the moment the balls look like they are sliding along the table at a constant speed. I have looked at alot of stuff on the web about this, but have not found anything i understand, i am not very good at maths, so has anyone got any simple solutions or something which i’ll understand?
Is there anything easier to understand out there, i.e. is there anyone who can provide me with simple steps to caculating the friction, force, etc, which is easy for someone who finds it difficult to understand complex mechanics
No. It’s just that complicated. You’ve to hammer it into your head as everyone else did
here is one way to do a math-lite simplified physics simulation:
try subtracting a constant amount from the velocity to add friction to your model. this will get you a simulated effect for the dynamic component of friction. for the static component of friction, you basically want to do the same thing, but make it apply only at the initial impact. this is basically the effect you feel when you have to slide a big box on the floor. it takes more force at first until the box breaks free, and then it slides much easier.
acceleration isn’t worth dealing with if you want to skip math and do simple simulated phyics.
collisions… not sure what a snooker table looks like, but there are basically two types of collision - elastic and inelastic. elastic collisions keep the energy of the collision in a kinetic form (rather than convert to heat). for billiard balls, this is what you want. you have to follow the conservation of momentum. something like mv of one particl must be equal to the mv of the other particle. since your billiard balls all have equal mass, you are really just passing the speed from one ball to another (assuming no spin).
now, the most difficult aspect of your game would be spin imparted by the cue. you could always have a spin component that each time step affects the path of the ball, and it may also affect the ball after the collision. the rate of spin generated will be directly proportional to the force of the cue impact and the distance away from the center of the back of the ball being struck. so, if you want a little spin, you hit slightly off center, etc, etc.
each time step
for all balls on table
if (speed > STATIC_THRESHOLD)
speed = speed - speed * COEFFICIENT_OF_FRICTION_DYNAMIC + spin
else
speed - speed - STATIC_THRESHOLD.
if speed < 0, speed = 0
i’ll leave the implementation of spin up to you, but it should also take friction into account. when i hit the ball hard and it spins real fast, that is dynamic friction. when the ball falls below some threshold speed, it grabs and the static friction sets in.
i haven’t talked about direction at all, but your simple simulated physics can account for everything by just having a speedX and a speedY.
Cheers for your help, that is really useful. But there is one more thing I am confused about, how do u know what angle the cue ball and the red ball will travel once they hit?
Thanks,
Daz
also forgot, what do you actually mean by static threshold, what could this be set at?
[quote]Cheers for your help, that is really useful. But there is one more thing I am confused about, how do u know what angle the cue ball and the red ball will travel once they hit?
[/quote]
i’m assuming you have not had a trigonometry class. that is the type of mathematics that would be helpful here.
let’s look at the simple case. draw a cue ball. now, draw two balls touching the cue ball (in front of it). now draw a line that represents the direction of the cue (it’s path). draw this line to the center point of the que. now, with the two balls touching the que ball, draw a line from the center of the que ball to the center of the other balls. that last line should be the direction the second ball is going.
but, how fast will the balls be traveling now? that will be tough to figure out without trig. but, we can still cheat without involving trig :> the clue is in the comparison of the angle made between the line of the cue’s path, and the line from the center of the que ball to the center of the ball about to be struck. between them is an angle. in your diagram you may have noticed that the larger the angle (or if you have a straight line - 180 degrees) then you will have the maximum transfer of force from the que ball. if you have a 90’ angle, then you have a glancing blow, where the queue will retain most of the energy (speed) and impart a bit on the queue. so, use your creativity to add some kind of ratio involving this angle into your calculation of how much force is given up by the que ball onto the the collision ball.
i think you are approaching the limits of what can be done without knowledge of physics and trig. if this interests you, trig is easy and fun. you can probably get the physics information you need by skimming here and there without delving too deeply in the mathematics.
[quote]also forgot, what do you actually mean by static threshold, what could this be set at?
[/quote]
static threshold is when the static friction no longer applies and thus we switch to dynamic. as i discussed, when you are sliding a heavy box, and all of sudden, it because easy to slide, that is the tipping point upon which you have reached the static friction threshold. you can google it and find all kinds of numbers for friction constants between surfaces. but, since you are not really doing a true physics model, the value should just be hand tweaked. after all, we are “hacking” physics. try a small value and increment it up until the collision looks realistic.
and, hit a used book store and buy a cheap physics book that has lots of diagrams. it will help you understand by allowing you to picture in your head of what is going on during these interactions.
best of luck,
jim