I know that when the center of mass is outside the body will fall down. But I am unable to express this in algorithm. I could make it work for a regular convex polygon (by finding if center of mass is outside of the contact surface). But how do I make it work for irregular convex polygon?
Basically, I need a clear idea of what kinds of forces are acting on the top body so that I am able to make it fall down due to gravity.