def test_rotation_signed_area(random_quat): """Ensure that rotating does not change the signed area.""" assume(not np.all(random_quat == 0)) random_quat = rowan.normalize(random_quat) rotated_points = rowan.rotate(random_quat, get_square_points()) poly = Polygon(rotated_points) assert np.isclose(poly.signed_area, 1) poly.reorder_verts(clockwise=True) assert np.isclose(poly.signed_area, -1)
def test_area(square_points): """Test area calculation.""" # Shift to ensure that the negative areas are subtracted as needed. points = np.asarray(square_points) + 2 square = Polygon(points) assert square.signed_area == 1 assert square.area == 1 # Ensure that area is signed. square.reorder_verts(True) assert square.signed_area == -1 assert square.area == 1