I am trying to create a simple model for collisions between a circle and a rectangle to be used in a computer game. The reason I am asking this question here rather than stack overflow is that the problem is not one of programming but rather of mechanics. The problem I am experiencing can be reduced to the following:
A circle with centre (cx,cy) collides with the top-left corner of a rectangle (rx,ry) The rectangle is stationary and cannot move. Given the circle collided with the rectangle at velocity (cvx,cvy), what velocity does the circle bounce off with, assuming the collision is perfectly elastic?
Next, consider that the rectangle is also moving with velocity (rvx,rvy), but its velocity is unaffected by a collision. What velocity does the circle bounce off with with, again assuming the collision is perfectly elastic?
This is similar to Angle of reflection off of a circle?, but the solution there does not seem applicable as a tangent cannot be drawn off the corner of a rectangle. Please note that I have not studied mechanics for over 2 years and then it was at a fairly low level.