# Circle Collision Resolution and Angular Momentum

I have a 2D engine working pretty well that involves rectangles and circles. I just reworked parts of the collision detection/response system for better handling of angular speed/momentum.

The collision response algorithm I'm using is described here: http://www.myphysicslab.com/collision.html (the complicated "j = ..." equations towards the bottom of the page under "Physics of Collision for Rigid Bodies in 2 Dimensions").

Everything's working great, but I'm wondering about circles. No matter how another another rectangle or circle hits a circle, it's impossible for the circle to gain angular speed through a collision, since the collision normal vector is always perpendicular to surface of the circle.

This makes sense to me mathematically, but it goes against my real-life intuition. For example, in the picture below, if I poke a ball on the side with a rectangle (tangentially, not towards the middle of the ball), I expect the ball to start spinning (counter-clockwise in this case). Why isn't this happening for me? Do I need some kind of non-instantaneous collision (deformation maybe?) to experience this effect? If so, is there a way to "fake" it? (Realistically! I don't want to mess up the realistic linear/angular momentums and energies of my system!) Thanks in advance for the help!!

• i like this question... intuitively, i think you're right, a purely rigid collision can't spin a circle. but as part of the collision handling, you could fake it, decide artistically how much energy to transfer to or from the spin vs the velocity. but eagerly awaiting more expert answer than that. Jul 1, 2015 at 21:35
• Torque comes from impulses that aren't directed towards the center of mass. Jul 1, 2015 at 22:28
• I am not experienced, but shouldn't you be using the rectangle's normal for the sphere's impulse and the sphere's normal for the rectangle's impulse? That way impulses would be directed not towards the center of mass, resulting in rotation/torque. Jul 1, 2015 at 22:35
• @akaltar The forces are equal and opposite (Newton's Law), you can't base them off of different normals for each shape or else the basic laws of motion are violated. And the only sane way to define a collision Normal for a circle (or sphere) is to go from the center of the circle to the point of contact (in other words, perpendicular to the surface, through the point of contact). I think the solution, like David said, will be to add some sort of frictional impulse/force, not to change the collision normals away from their current correct values. I am also eagerly awaiting an expert answer :) Jul 1, 2015 at 22:41
• @davidvanbrink : of cource a purely rigid collision CAN spin a circle, unless it is purely frictionless. If you have 2 materials made of rubber you'll have a high spin. this is because the contact force does apply in the direction depicted by the red arrow here. You can consider a fully not-slipping contact like a pivot link (cinematic liaison). And then it works like bicycle pedals. Aug 5, 2015 at 8:58

You need a tensor for a generic solution. but the "specialized" solution here is that you have a a spin only if you have friction in your contact. otherwise of course the contact forces will purely be directed to the center of the circle and never cause spin. if you have friction, your forces will start to deviate within the realms of the friction cone, which is then, not-anymore-center directed. This contact force will work against the inertia of your circle that applies at the center of mass. Both forces create a couple, which is a torque. this torque is determined is classical analytic mechanics using a cross product of the force vector and the lever vector.

From memory, the reduction of force in a point (to find a net force (or resultant) will give you a 2-components force, a force and a torque, directly. You "just" have to create a segment vector that links the center of mass to your contact point (subtract points A-B=BA) and then cross-product it with your contact force, you get the torque component. This is the "lever effect". You can see that the more orthogonal the force gets, the greater the torque, or the farther away the contact is, the greater the torque. The 1st component is just a copy of the linear force.

You can treat your contact as an impulse if it is supposed to happen in only one simulation frame. Also you can consider about 2 possibilities for the colliding stick:
- infinitely heavy (because handled by some infinitely powerful virtual hand ?)
- or free, like the circle, and then the amount of energy transmitted in the circle will have to be determined by "momentum" repartition p=m*v (momentum="quantity of movement").

F = m * v/t

For you it means diving by your simulation dt because the contact is instantaneous, and this creates the impulse.

The rotation will not happen directly as a result of the torque you calculate, there is the equivalent in rotation to the linear inertia, which is called angular inertia.
linear inertia is given by the mass, simply. This is natural to understand why because that's what happen with movement forumlas (from Netwon's f=ma).
The mass is resisting the force applied to give birth to an acceleration.
In rotation, it is the same, the moment of inertia, is resisting the torque to create a spin.
One can find the moment of inertia by integrating the elements of surface over the shape (called second moment of mass), which for special shapes you can find pre-calculated on internet. for example for your circle you could say it's a cylinder and use 1/2 mr2.

And the final touch is given by torque = I * alpha which is f=ma written in rotation form, so you know the torque because you calculated it using the cross product afore-mentioned, you know I because it is 1/2 mass radius squared and so you know alpha: (alpha = t/I) which is the angular acceleration, so then you just have to integrate over time to get the angular speed and finally angle after a second integration. (using Euler, Verlet, or Runge kutta, whatever).

Edit: About the concern of contact point being infinitely small and not capable of having friction: this is unrelated to the cinematic study, we can perfectly sanely infer that friction exists without any more justification. If in need for justification then you can imagine sticking a needle on a glass panel, this doesn't slip perfectly, it slips but has some amount of friction.
Also if you accept imagining that molecules can intertwine even a micro contact will be enough to get forces laterally transmitted. This especially happens easily on cold materials. (cold = less movement, thus more opportunities to fall in holes. imagine a rotating fan, if you push on it you can't go through, but if it is off, you just have to stick your finger in between the wings)

ODE creates temporary linkage in case of contacts, in this case it would create a ball joint during the simulation dt.

nice sum up here of linear / rotational parallels:
http://hyperphysics.phy-astr.gsu.edu/hbase/mi.html