Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit272c728

Browse files
committed
Numpified transforms.py, fixed bug in invert_vec6
svn path=/trunk/matplotlib/; revision=3408
1 parent816f4b0 commit272c728

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

‎lib/matplotlib/transforms.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@
126126
c = sy*sin(alpha);
127127
d = sy*cos(alpha);
128128
129+
The affine transformation can be accomplished for row vectors with a
130+
single matrix multiplication
131+
X_new = X_old * M
132+
where
133+
M = [ a b 0
134+
c d 0
135+
tx ty 1]
136+
and each X is the row vector [x, y, 1]. Hence M is
137+
the transpose of the matrix representation given in
138+
http://en.wikipedia.org/wiki/Affine_transformation,
139+
which is for the more usual column-vector representation
140+
of the position.)
141+
142+
143+
129144
From a user perspective, the most important Tranformation methods are
130145
131146
All transformations
@@ -233,13 +248,13 @@
233248
and attributes to Bbox and/or putting them elsewhere in this module.
234249
"""
235250
from __future__importdivision
236-
237251
importmath
238-
from_transformsimportValue,Point,Interval,Bbox,Affine
239-
from_transformsimportIDENTITY,LOG10,POLAR,Func,FuncXY
240-
from_transformsimportSeparableTransformation,NonseparableTransformation
241-
frommatplotlib.numeriximportarray,Float
242-
frommatplotlib.numerix.linear_algebraimportinverse
252+
importnumpyasnpy
253+
254+
frommatplotlib._transformsimportValue,Point,Interval,Bbox,Affine
255+
frommatplotlib._transformsimportIDENTITY,LOG10,POLAR,Func,FuncXY
256+
frommatplotlib._transformsimportSeparableTransformation
257+
frommatplotlib._transformsimportNonseparableTransformation
243258

244259
defnonsingular(vmin,vmax,expander=0.001,tiny=1e-15,increasing=True):
245260
'''
@@ -249,7 +264,8 @@ def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
249264
the maximum absolute value.
250265
251266
If they are too close, each will be moved by the 'expander'.
252-
If 'increasing' is True and vmin > vmax, they will be swapped.
267+
If 'increasing' is True and vmin > vmax, they will be swapped,
268+
regardless of whether they are too close.
253269
'''
254270
swapped=False
255271
ifvmax<vmin:
@@ -372,19 +388,13 @@ def lbwh_to_bbox(l,b,w,h):
372388

373389
definvert_vec6(v):
374390
"""
375-
v is a,b,c,d,tx,ty vec6 repr of a matrix
376-
[ a b 0
377-
c d 0
378-
tx ty 1]
379-
391+
v is a,b,c,d,tx,ty vec6 repr of an affine transformation.
380392
Return the inverse of v as a vec6
381393
"""
382-
M=array([ [a,b,0], [c,d,0], [tx,ty,1]],typecode=Float)
383-
Mi=inverse(M)
384-
a,b=M[0,0:2]
385-
c,d=M[1,0:2]
386-
tx,ty=M[2,0:2]
387-
returna,b,c,d,tx,ty
394+
a,b,c,d,tx,ty=v
395+
M=npy.array([ [a,b,0], [c,d,0], [tx,ty,1]],dtype=npy.float64)
396+
Mi=npy.linalg.inv(M)
397+
returnMi[:,:2].ravel()
388398

389399
defmultiply_affines(v1,v2):
390400
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp