A Stable Relationship

From programming_contest
Jump to: navigation, search

All that matters is the center of mass of the object. As each object is printed, calculate the new COM of the tower (note: we only care about x/y here...the z component is irrelevant). The easiest way to do this is to treat each block as a point mass located at the center of the block. This is just summing up all the positions and dividing by the number of blocks. Then we have to check whether that center of mass is within the boundaries of the convex hull of the base.