()
| 56 | |
| 57 | |
| 58 | def test_corner_center(): |
| 59 | loc = [10, 20] |
| 60 | width = 1 |
| 61 | height = 2 |
| 62 | |
| 63 | # Rectangle |
| 64 | # No rotation |
| 65 | corners = ((10, 20), (11, 20), (11, 22), (10, 22)) |
| 66 | rect = Rectangle(loc, width, height) |
| 67 | assert_array_equal(rect.get_corners(), corners) |
| 68 | assert_array_equal(rect.get_center(), (10.5, 21)) |
| 69 | |
| 70 | # 90 deg rotation |
| 71 | corners_rot = ((10, 20), (10, 21), (8, 21), (8, 20)) |
| 72 | rect.set_angle(90) |
| 73 | assert_array_equal(rect.get_corners(), corners_rot) |
| 74 | assert_array_equal(rect.get_center(), (9, 20.5)) |
| 75 | |
| 76 | # Rotation not a multiple of 90 deg |
| 77 | theta = 33 |
| 78 | t = mtransforms.Affine2D().rotate_around(*loc, np.deg2rad(theta)) |
| 79 | corners_rot = t.transform(corners) |
| 80 | rect.set_angle(theta) |
| 81 | assert_almost_equal(rect.get_corners(), corners_rot) |
| 82 | |
| 83 | # Ellipse |
| 84 | loc = [loc[0] + width / 2, |
| 85 | loc[1] + height / 2] |
| 86 | ellipse = Ellipse(loc, width, height) |
| 87 | |
| 88 | # No rotation |
| 89 | assert_array_equal(ellipse.get_corners(), corners) |
| 90 | |
| 91 | # 90 deg rotation |
| 92 | corners_rot = ((11.5, 20.5), (11.5, 21.5), (9.5, 21.5), (9.5, 20.5)) |
| 93 | ellipse.set_angle(90) |
| 94 | assert_array_equal(ellipse.get_corners(), corners_rot) |
| 95 | # Rotation shouldn't change ellipse center |
| 96 | assert_array_equal(ellipse.get_center(), loc) |
| 97 | |
| 98 | # Rotation not a multiple of 90 deg |
| 99 | theta = 33 |
| 100 | t = mtransforms.Affine2D().rotate_around(*loc, np.deg2rad(theta)) |
| 101 | corners_rot = t.transform(corners) |
| 102 | ellipse.set_angle(theta) |
| 103 | assert_almost_equal(ellipse.get_corners(), corners_rot) |
| 104 | |
| 105 | |
| 106 | def test_ellipse_vertices(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…