FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Billiard Ball Physics with Spin

 


ninjakannon
Okay, I had no idea which forum to stick this into so I thought I might as well try here. It's physics and maths...

I'm using Flash 8 to simulate billiard ball physics, but not to create a billiards game or something similar.

So far I have balls of any size and mass that can collide with each other and vertical or horizontal boundaries. Now I'm trying to add spin (only using movieclips rotation property - nothing pseudo-3D).

I'm not doing anything with moments of inertia or coefficients of restitution etc. Each ball currently has the following relevant properties: radius, mass, vx (x velocity), vy (y velocity) and vr (rotational / angular velocity).

I want the balls to change their spin when they collide with other balls (any angle) and the boundaries - it would also be useful to work something out for colliding with boundaries of any angle. The spin should also affect the collision reactions of these.

I know there's physics for this, but my text books don't cover any of it!

Any tips or help would be greatly appreciated, I'm a little stuck. Smile
Indi
When you say spin, do you mean top spin or side spin ("english")?

Either way it comes down to a friction calculation. What type depends on whether you're talking about top spin or english.
ninjakannon
Oh, it's side spin.

The balls are viewed as though from top down and will rotate around their centre points.
Indi
Ah, i got the picture in my head now.

Unfortunately, i can't rattle off the equations for side spin as easily as top spin, but i'll see what help i can give you. Now this stuff can get really complicated, really quickly - complicated as in graduate level physics and beyond. Just to be able to even conceptualize the problem, i'll have to make a load of simplifying assumptions - but i'll try and say what they all are, and put them in as footnotes.

Let's start with what the spin does to the ball itself as it moves along without hitting anything else. First, the spin won't last forever - friction with the table will slowly stop the spin. i actually don't know the equation to calculate this friction off the top of my head¹, but it's really not such a big deal to fake it. Just decrease vr linearly with time - like for every game tick, subtract a constant amount from vr until it's 0. All you have to do is figure out what value to keep subtracting, and you can use trial and error or estimation for that. The result will be very close to true behaviour, if you guess the value right.

Eq. 1: |vr(t1)| = max(|vr(t0)| - fa, 0)


Next, the spin will cause the path of the ball to curve very slightly. You can probably get away with ignoring this - depends on how accurate you want the simulation. What's happening is the axis of spin will never be perfectly perpendicular to the table, and even if it is, your contact area is a circle, not a point, so you would get a small torque.² If you had a big enough table and no friction, you'd actually see the ball travel in a huge circle. To fake this, all you'd have to do is take the unit vector of travel, find the perpendicular vector (just swap the x and y components in 2D), and then scale by some factor of vr. The bigger vr is (the faster the ball is spinning) the more curve you will get.

Eq. 2: (ux, uy) is the unit vector in the direction of (vx, vy)
vx(t1) = vx(t0) + (uy(t0) * vr(t0) * fb)
vy(t1) = vy(t0) + (ux(t0) * vr(t0) * fb)


Alright, now to what happens when the ball hits the rail. Whenever two objects collide, they are in contact for a finite amount of time. Picture a basketball bouncing on the court surface - the ball touches the court surface, then compresses, then expands, then leaves the court surface (and although you can't really see it, the court surface compresses a bit, too). In the time during that compression and expansion is where all the magic happens.

If you want to model this accurately, the first thing you have to do is figure out how much contact time there is, then use that time and the rotational speed of the ball(s) to find the frictional force imparted.³ Needless to say... this would be a bitch to do. Much easier is to use yet another fudge factor. You'd want to factor in the force of the impact (that is, the relative speeds of the two balls or the ball and the rail), the type of impact (ball on ball or ball on wall) and the speed of rotation. When two balls hit, you take away some rotation from each ball, and add it to the other (maybe a little less than what you take away to account for loss of energy). When a ball and the wall hit, you take away some rotation and add some velocity in the direction of spin.

There are only two more things to take into account. First, spin caused by off-center hits. This is easy - all you have to do is take the vector sum of the two velocities (of the two balls or of the ball and the wall - one can be zero of course), and then break it into components - one along the line of impact and one perpendicular. The one along the line of impact causes motion, the one perpedicular causes spin. And i forget what the other thing is. ^_^; i got distracted.

Anyway, the moral of the story is that you can make this really, really hard on yourself by trying to model it very accurately, or you can just fudge it.




¹ The basic Coulomb equation F = μ × N applies, but in order to determine the effect of that friction force on the spin, you have to sum it over the contact area between the ball and the table. The contact area will be a circle, so you would need to do a two dimensional integration of the force over the circular area. That's not really hard, but i'm not gonna do it. ^_^;

² Again, to calculate this you would need to integrate the friction over the circular contact area. It's actually the same equation as above. Action equals reaction - the force that is slowing down the spin also induces the curved path.

³ This is a really, really complex calculation. For example, just to determine the frictional force of the contact, you have to do an integration over the whole contact time, because F = μ × N and N is changing throughout the impact.
ninjakannon
Thanks for the great response Indi!

I've read through and had a little think about it all - looks like that's everything I need. Unfortunately, I'm in the middle of exams at the moment so I won't have time have a proper look at this for a week or so. When I do though, I'll get back on here with either some problems or, hopefully, the finished result.

Thanks again, this is a huge help!
ninjakannon
Indi, if you're interested take a look here.

I haven't included either physics for bouncing off the walls or the maths to curve the path of the ball as I've experienced problems with both (hence the time this has taken me, on and off). I hope to add these features later, but make no promises.
Bikerman
Looks like a good first approximation to me Smile
liljp617
Indi, may I ask how the hell you know EVERYTHING? lol Very Happy
Reply to topic    Frihost Forum Index -> Science -> General Science

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.