completed functions to operate on triangles and rectangles