@@ -81,40 +81,6 @@ def strrepr(x): return repr(x) if isinstance(x, str) else str(x)
81
81
+ ")" )
82
82
83
83
84
- def matrix_transform (vertices , mtx ):
85
- """
86
- Transforms a vertex or set of vertices with a matrix mtx of
87
- one dimension higher.
88
-
89
- Parameters
90
- ----------
91
- vertices : n-element array or (m, n) array, with m vertices
92
- mtx : (n+1, n+1) matrix
93
- """
94
- values = np .asanyarray (vertices )
95
- _ , input_dims = mtx .shape
96
- input_dims = input_dims - 1
97
-
98
- if (len (values .shape ) == 1 ):
99
- # single point
100
- if (values .shape == (input_dims ,)):
101
- point = mtx .dot (np .append (values , [1 ]))
102
- point = point / point [- 1 ]
103
- return point [:input_dims ]
104
- raise RuntimeError ("Invalid vertices provided to transform" )
105
-
106
- # multiple points
107
- if (len (values .shape ) == 2 and values .shape [1 ] == input_dims ):
108
- points = np .hstack ((values , np .ones ((values .shape [0 ], 1 ))))
109
- points = np .dot (mtx , points .T ).T
110
- last_coords = points [:, - 1 ]
111
- points = points / last_coords [:, np .newaxis ]
112
- return points [:, :- 1 ]
113
-
114
- raise ValueError ("Dimensions of input must match the input dimensions of "
115
- "the transform" )
116
-
117
-
118
84
class TransformNode :
119
85
"""
120
86
The base class for anything that participates in the transform tree
@@ -2361,7 +2327,7 @@ def rotate_around_vector(self, vector, theta):
2361
2327
np .matmul (rot , self ._mtx , out = self ._mtx )
2362
2328
return self
2363
2329
2364
- def rotate_around_vector_deg (self , vector , degrees ):
2330
+ def rotate_deg_around_vector (self , vector , degrees ):
2365
2331
"""
2366
2332
Add a rotation (in radians) around the vector (vx, vy, vz) in place.
2367
2333
@@ -3377,3 +3343,37 @@ def offset_copy(trans, fig=None, x=0.0, y=0.0, units='inches'):
3377
3343
y /= 72.0
3378
3344
# Default units are 'inches'
3379
3345
return trans + ScaledTranslation (x , y , fig .dpi_scale_trans )
3346
+
3347
+
3348
+ def matrix_transform (vertices , mtx ):
3349
+ """
3350
+ Transforms a vertex or set of vertices with a matrix mtx of
3351
+ one dimension higher.
3352
+
3353
+ Parameters
3354
+ ----------
3355
+ vertices : n-element array or (m, n) array, with m vertices
3356
+ mtx : (n+1, n+1) matrix
3357
+ """
3358
+ values = np .asanyarray (vertices )
3359
+ _ , input_dims = mtx .shape
3360
+ input_dims = input_dims - 1
3361
+
3362
+ if (len (values .shape ) == 1 ):
3363
+ # single point
3364
+ if (values .shape == (input_dims ,)):
3365
+ point = mtx .dot (np .append (values , [1 ]))
3366
+ point = point / point [- 1 ]
3367
+ return point [:input_dims ]
3368
+ raise RuntimeError ("Invalid vertices provided to transform" )
3369
+
3370
+ # multiple points
3371
+ if (len (values .shape ) == 2 and values .shape [1 ] == input_dims ):
3372
+ points = np .hstack ((values , np .ones ((values .shape [0 ], 1 ))))
3373
+ points = np .dot (mtx , points .T ).T
3374
+ last_coords = points [:, - 1 ]
3375
+ points = points / last_coords [:, np .newaxis ]
3376
+ return points [:, :- 1 ]
3377
+
3378
+ raise ValueError ("Dimensions of input must match the input dimensions of "
3379
+ "the transform" )
0 commit comments