Refine housepart grid algorithm to make it compatible with rotation