Ball Collision vb.net

Started by
2 comments, last by beswim 9 years, 9 months ago

Does anyone know of a tutorial on how to do Ball collision for a pool table?

Advertisement

Googling for "pool ball collision tutorial" yields ~3.5 million hits. A couple of them look pretty thorough. You'll have to brush up on your physics a bit, if you're not already familiar with the concepts.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Will do.


 If c <= 28 Then


            Ball3X = OvalShape2.Width / 2
            Ball3Y = OvalShape2.Height / 2


            tangent = Math.Abs(Ball3X ^ 2 + Ball3Y ^ 2)
            tangent2 = Math.Sqrt(tangent)
            finalangle = Math.Acos(Ball3X / tangent2)
            finalang = Math.Acos(finalangle)


            finalangle5 = Math.Asin(Ball3Y / tangent2)
            finalangle6 = Math.Asin(finalangle5)

            tangent12 = finalangle6 / finalang




            Ball4X = OvalShape16.Width / 2
            Ball4Y = OvalShape16.Height / 2

            tangent10 = Ball4X ^ 2 + Ball4Y ^ 2
            tangent11 = Math.Sqrt(tangent10)
            finalang2 = Math.Acos(Ball4X / tangent11)
            finalangle5 = Ball4X * Math.Cos(finalang2)


            finalangle7 = Math.Asin(Ball4Y / tangent11)
            finalangle8 = Ball4Y * Math.Sin(finalangle7)

            tangent7 = finalangle5 / finalangle8



            SpeedX = finalangle5
            SpeedY = finalangle8
            speedX2 = -finalangle
            speedY2 = finalangle6

        End If

I have this code to check to see if the distance is less than the radius of the two balls. I put inside this code to check when the balls collide and at what angle its colliding at. Then I want to send the balls in their x,y cosine sine angles. Can someone tell me if I'm doing this right?

This topic is closed to new replies.

Advertisement