Sign in to follow this  

math question

This topic is 3624 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, How do you hit a sphere with another sphere to make it go in a specific direction? I need to know this to be able to play against the computer with my game. For the record, it's a billiard game. Thanks in advance!

Share this post


Link to post
Share on other sites
Because in billards all of the spheres are on a level plane, we can think of them all as circles. To find out if two circles are colliding, you must check the distance between the two sphere's centers, and if that dist is less than or equal to the sum of the two circle's radii, then they are touching.

Bounding circles is easy, but making them bounce off of one another is a bit harder. You would have to apply some physics to it, using 2-dimensional collisions. I personally do not like doing those problems. You do need to have a basic understanding of momentum and kinetic energy of objects in order to solve those kinds of equations. Trigonometry also helps.

Read up on some tutorials on the internet, or if you have a physics book, go back and check on that stuff.

Good luck!
S. C. B.

Share this post


Link to post
Share on other sites
Quote:
Original post by EvanWeeks
You did google the physics of billiards, correct?



Hi EvanWeeks,

I have googled. But i haven't come a cross where they discuss the angle of impact on a sphere to make it go in a specific direction, or i over looked it.


Quote:
Original post by sykosnakesix
Because in billards all of the spheres are on a level plane, we can think of them all as circles. To find out if two circles are colliding, you must check the distance between the two sphere's centers, and if that dist is less than or equal to the sum of the two circle's radii, then they are touching.

Bounding circles is easy, but making them bounce off of one another is a bit harder. You would have to apply some physics to it, using 2-dimensional collisions. I personally do not like doing those problems. You do need to have a basic understanding of momentum and kinetic energy of objects in order to solve those kinds of equations. Trigonometry also helps.

Read up on some tutorials on the internet, or if you have a physics book, go back and check on that stuff.

Good luck!
S. C. B.



Hi sykosnakesix,

I got a 3d engine and a physics engine in my game. The game is already playable.

But my problem is, how can i give the computer the same ability to win a game?

I can make the computer hit a sphere. But i don't know how to make it hit on a specific angle.

Share this post


Link to post
Share on other sites
So, if I understand you correctly, you already have a working physics simulation where the billiard balls collide and react appropriately, and the problem you're having is how to have a computer-player aim on an appropriate angle to score? If so:

Work backwards from the result you want. For a given ballwith a known target pocket (or location if you want to move it but not sink it) calculate a straight line from the centre of the target location through the centre of the ball - where this line intersects with the side of the ball which is more distant from your target location is the point on that ball you need to have the cue-ball impact the target ball. Apologies for the incredibly poor graphic, but perhaps this will help you out a bit...


If you need to figure out which ball you want to hit, a simple method would be to simply perform these calculations for each possible ball, ruling out any for which the target shot cannot possibly be made, and then choosing one for which it is possible - bonus points for calculating where the cue-ball will end up and choosing one that has at least one possible "next shot". To make it a bit more fun you'd want to have the computer player not always be completely accurate.


Hope that's of some help...

Share this post


Link to post
Share on other sites
Quote:
Original post by jbadams
So, if I understand you correctly, you already have a working physics simulation where the billiard balls collide and react appropriately, and the problem you're having is how to have a computer-player aim on an appropriate angle to score? If so:

Work backwards from the result you want. For a given ballwith a known target pocket (or location if you want to move it but not sink it) calculate a straight line from the centre of the target location through the centre of the ball - where this line intersects with the side of the ball which is more distant from your target location is the point on that ball you need to have the cue-ball impact the target ball. Apologies for the incredibly poor graphic, but perhaps this will help you out a bit...


If you need to figure out which ball you want to hit, a simple method would be to simply perform these calculations for each possible ball, ruling out any for which the target shot cannot possibly be made, and then choosing one for which it is possible - bonus points for calculating where the cue-ball will end up and choosing one that has at least one possible "next shot". To make it a bit more fun you'd want to have the computer player not always be completely accurate.


Hope that's of some help...



Hi jbadams,

Thank you very much for your explanation!


Quote:
Original post by jbadams
So, if I understand you correctly, you already have a working physics simulation where the billiard balls collide and react appropriately, and the problem you're having is how to have a computer-player aim on an appropriate angle to score? If so:



You understood me correctly.

No need to apologies for the graphic, its perfect!

It gave me a good idea how to get this done.

The game is more like a death match variant of the billiard game.

There are only 2 spheres in the game and the rules are simple. Try to make each other fall in one of the holes.

However, i do have a small question. Does it matter how hard the sphere impacts or not? I mean will this have an effect on the direction it suppose to move?

Thanks in advance!

Share this post


Link to post
Share on other sites
Quote:
Original post by Yustme
However, i do have a small question. Does it matter how hard the sphere impacts or not? I mean will this have an effect on the direction it suppose to move?
If your physics simulation includes friction then it may make a small difference, but you can probably safely assume this to be negligable. It will however of course effect how far the balls travel, which may have consequences if either of them bounce off the sides of the table, or if the chosen angle might cause the player's own ball to be sunk after impacting the other one.

Share this post


Link to post
Share on other sites
Quote:
Original post by jbadams
Quote:
Original post by Yustme
However, i do have a small question. Does it matter how hard the sphere impacts or not? I mean will this have an effect on the direction it suppose to move?
If your physics simulation includes friction then it may make a small difference, but you can probably safely assume this to be negligable. It will however of course effect how far the balls travel, which may have consequences if either of them bounce off the sides of the table, or if the chosen angle might cause the player's own ball to be sunk after impacting the other one.



Hi jbadams,

The physics simulation does contain friction. I wanted to know this information for making the backtracking a little bit less accurate as a possibility.

Suppose the player's own ball falls in one of the holes. The opponent gets a point, that simple :P

Thank you very much for the info jbadams!

Share this post


Link to post
Share on other sites

This topic is 3624 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this