Completed ZPiece rotation algorithm