1

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.

Sepia
  • 113
  • Why do you want to have a collision at the angle? Angles are points of singularity when calculating normals to the surface, and those you will need when modeling collision. What you can do is to approximate angles with some smooth surfaces at the very vicinity, so normals will be continuous. – Kaster Jun 24 '13 at 19:18
  • @Kaster Thank you for your response. I am modelling the situation in which a circle hits a rectangle on its corner. I have already considered the cases in which it is hit on a side. Rounding the corners of the rectangle would not be at all easy and require a complete rethink of the way I'm currently doing the collision detection. It would also be changing what is being modelled such that it would no longer be relevant. Surely there is a way of modelling this situation without changing it. – Sepia Jun 24 '13 at 19:32
  • as I said, there's no way you can model that. Corner is singular. You can say that circle goes to any randomly chosen direction, if it's point-to-point interaction. If the collision's indeed elastic so circle can be reshaped under the pressure, then bouncing direction might depend on from which side circle hit the corner, i.e. which side containing that corned made most influence to the collision. But in this case much more physics and therefore modeling is involved. – Kaster Jun 24 '13 at 19:45
  • What about setting up a reference frame centered at the circle's center? Then the previously stationary point (corner) becomes in the new reference frame a moving point. This moving point will then bounce off the (now stationary) circle by considering the tangent to the circle at the point of impact. However I'm not sure how the velocities get transformed using this other reference frame. – coffeemath Jun 24 '13 at 19:56
  • @coffeemath Thank-you for your suggestion. I spent a bit of time trying it and it may work, but I got lost quite quickly with the changing frame of reference. Hagen von Eitzen's solution is a lot easier for me to implement. – Sepia Jun 24 '13 at 22:53

1 Answers1

1

Physically, the force exerted on the circle during collision acts radially on the line through the vertex of the rectangle and the center (of gravity) of the circle. This is true at least as far as the momentum is concerned; some kinetic energy may be converted (via tangential force) to rotational energy, with the details depending on the "surface structure" and friction. By your assumption that the rectangle is not affected, we should assume that the rectangle has infinite mass and no energy is transferred between the two objects (whereas momentum is, but that doesn't matter for the rectangle).

If at the moment of collision the circle center is at $(c_x,c_y)$ and the corner at $(r_x,r_y)$ and the velocity before is $(v_x,v_y)$, then the velocity after the collision is determined by $(v_x',v_y')=(v_x+q(c_x-r_x), v_y+q(c_y-r_y))$ and - assuming for simplicity that no rotation is produced - same kinetic energy: $v'^2=v^2$. You can use this to find the nonzero solution for $q$ and hence the new velocity: $$\begin{align}v_x^2+v_y^2&=(v_x+q(c_x-r_x))^2+(v_y+q(c_y-r_y))^2\\ \implies\quad0&=2q(v_x(c_x-r_x)+v_y(c_y-r_y))+q^2((c_x-r_x)^2+(c_y-r_y))^2\\ \implies \quad q&=-\frac{2(v_x(c_x-r_x)+v_y(c_y-r_y))}{R^2} \end{align}$$ where $R$ is the radius of your circle.

If the rectangle (still of infinite mass) is moving, it is best to assume the rectangle at rest (or rather the common center of gravity - but that is the center of gravity of the rectangle), i.e. you first subtract the rectangle velocity from the circle velocity, then compute the new circle velocity and add back the rectangle velocity.

More realistically, however, you really do have to consider rotational energy (pre and post collision) as well.

  • Brilliant, using these formulae for q and the new velocity causes the model to work as expected. Thank-you very much for your help. – Sepia Jun 24 '13 at 22:51