Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 45de25e

Browse filesBrowse files
authored
Merge pull request #22108 from anntzer/fr
Micro-optimize rotation transform.
2 parents 14a94c3 + ff120cd commit 45de25e
Copy full SHA for 45de25e

File tree

1 file changed

+10
-3
lines changed
Filter options

1 file changed

+10
-3
lines changed

‎lib/matplotlib/transforms.py

Copy file name to clipboardExpand all lines: lib/matplotlib/transforms.py
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,9 +2002,16 @@ def rotate(self, theta):
20022002
"""
20032003
a = math.cos(theta)
20042004
b = math.sin(theta)
2005-
rotate_mtx = np.array([[a, -b, 0.0], [b, a, 0.0], [0.0, 0.0, 1.0]],
2006-
float)
2007-
self._mtx = np.dot(rotate_mtx, self._mtx)
2005+
mtx = self._mtx
2006+
# Operating and assigning one scalar at a time is much faster.
2007+
(xx, xy, x0), (yx, yy, y0), _ = mtx.tolist()
2008+
# mtx = [[a -b 0], [b a 0], [0 0 1]] * mtx
2009+
mtx[0, 0] = a * xx - b * yx
2010+
mtx[0, 1] = a * xy - b * yy
2011+
mtx[0, 2] = a * x0 - b * y0
2012+
mtx[1, 0] = b * xx + a * yx
2013+
mtx[1, 1] = b * xy + a * yy
2014+
mtx[1, 2] = b * x0 + a * y0
20082015
self.invalidate()
20092016
return self
20102017

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.