MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_rotate_rect

Function test_rotate_rect

lib/matplotlib/tests/test_patches.py:157–178  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

155
156
157def test_rotate_rect():
158 loc = np.asarray([1.0, 2.0])
159 width = 2
160 height = 3
161 angle = 30.0
162
163 # A rotated rectangle
164 rect1 = Rectangle(loc, width, height, angle=angle)
165
166 # A non-rotated rectangle
167 rect2 = Rectangle(loc, width, height)
168
169 # Set up an explicit rotation matrix (in radians)
170 angle_rad = np.pi * angle / 180.0
171 rotation_matrix = np.array([[np.cos(angle_rad), -np.sin(angle_rad)],
172 [np.sin(angle_rad), np.cos(angle_rad)]])
173
174 # Translate to origin, rotate each vertex, and then translate back
175 new_verts = np.inner(rotation_matrix, rect2.get_verts() - loc).T + loc
176
177 # They should be the same
178 assert_almost_equal(rect1.get_verts(), new_verts)
179
180
181@check_figures_equal()

Callers

nothing calls this directly

Calls 2

RectangleClass · 0.90
get_vertsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…