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 8ad61bd

Browse filesBrowse files
Speed up calculations for default tilt=0
1 parent f3846da commit 8ad61bd
Copy full SHA for 8ad61bd

File tree

Expand file treeCollapse file tree

1 file changed

+9
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-8
lines changed

‎lib/mpl_toolkits/mplot3d/proj3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/proj3d.py
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def rotation_about_vector(v, angle):
5555
"""
5656
Produce a rotation matrix for an angle in radians about a vector.
5757
"""
58-
v /= np.linalg.norm(v)
58+
v = v/np.linalg.norm(v)
5959
s = np.sin(angle)
6060
c = np.cos(angle)
6161
t = 1-c
@@ -73,15 +73,16 @@ def view_transformation(E, R, V, tilt):
7373
n = n/np.linalg.norm(n)
7474
u = np.cross(V, n)
7575
u = u/np.linalg.norm(u)
76-
v = np.cross(n, u)
77-
v = v/np.linalg.norm(v)
76+
v = np.cross(n, u) # Will be a unit vector
7877

79-
Rtilt = rotation_about_vector(n, tilt)
80-
u = np.dot(Rtilt, u)
81-
v = np.dot(Rtilt, v)
78+
# Save some computation for the default tilt=0
79+
if tilt != 0:
80+
Rtilt = rotation_about_vector(n, tilt)
81+
u = np.dot(Rtilt, u)
82+
v = np.dot(Rtilt, v)
8283

83-
Mr = np.diag([1.] * 4)
84-
Mt = np.diag([1.] * 4)
84+
Mr = np.eye(4)
85+
Mt = np.eye(4)
8586
Mr[:3, :3] = [u, v, n]
8687
Mt[:3, -1] = -E
8788

0 commit comments

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