def center_of_mass(vertices):
    """
    Return center of mass of polygon spanned by vertex list.

    Parameters
    ----------
    vertices : N x 2 np.ndarray

    Returns
    -------
    center : 1 x 2 np.ndarray
    """
    center = np.array([0, 0], dtype='float')
    area = find_area_of_polygon(vertices)
    decomposition = decompose_to_triangles(vertices)

    for triangle in decomposition:
        area_of_triangle = find_area_of_polygon(triangle)
        center_of_triangle = find_center_of_mass_triangle(triangle)
        center += area_of_triangle*center_of_triangle
    
    center = (1/area)*center

    return center
 def test_area_pentagon(self):
     # Make sure area is correct for pentagon.
     self.assertEqual(find_area_of_polygon(self.pentagon), 3.5)
 def test_area_trapezoid(self):
     # Make sure area is correct for trapezoid.
     self.assertEqual(find_area_of_polygon(self.trapezoid), 1.5)
 def test_area_square(self):
     # Make sure area is correct for square.
     self.assertEqual(find_area_of_polygon(self.square), 1.0)
 def test_area_triangle2(self):
     # Make sure area is correct for another triangle.
     self.assertEqual(find_area_of_polygon(self.triangle2), 1.0)
 def test_area_triangle1(self):
     # Make sure area is correct for triangle.
     self.assertEqual(find_area_of_polygon(self.triangle1), 0.5)