Luke Fairway
Luke Fairway

Reputation: 87

Bounce A Ball of off a Circle

So I am making a game that's like slime volleyball. Basically, my two main players, or objects, are half circles on either side, I have a net in the middle, and a ball. My problem is I can't figure out how to make the ball bounce of a semi circle so that it follows both the angle and direction. I've tried looking it up, but all of them are either about walls or rectangles, not bouncing off a circular object. Any code or ideas would help.

Upvotes: 3

Views: 861

Answers (1)

Joseph O'Rourke
Joseph O'Rourke

Reputation: 4406

"Take a semicircle, point it upwards, shine parallel rays of light straight down at it, and let those rays reflect off it. The envelope of the reflected rays will be half of a nephroid":


          ParallelRaysCirc
          Image source: John Baez.
More directly, assume you have a ray r along your ball path. Find the intersection point p of r with your semicircle C. Compute the tangent t at p. Compute the normal n at p. Reflect r over n to r'.

Upvotes: 1

Related Questions