Search code examples
game-physics

Ball and ellipse collision


As an exercise I'm trying to implement a pong like game and trying to use a elliptical shapes as the paddles. Can somebody help me to calculate the direction of the ball after the ball and the paddle collide?

what I'm trying to do
I'm interested in the math part of the calculation, and not some library that can calculate it for me.


Solution

  • Let n be a unit vector normal to the surface of the ellipse at the point of contact. (You can find how to calculate such a vector e.g. here.) Let v be a vector along which the ball is approaching; it will leave along the vector

    u = v - 2(v.n)n
    

    where . is the dot-product.