@@ -1340,7 +1340,7 @@ def getpoints(self, x1, y1, x2, y2, k):
1340
1340
line and intersects (*x2*, *y2*) and the distance from (*x2*,
1341
1341
*y2*) of the returned points is *k*.
1342
1342
"""
1343
- x1 , y1 , x2 , y2 , k = list ( map (float , (x1 , y1 , x2 , y2 , k ) ))
1343
+ x1 , y1 , x2 , y2 , k = map (float , (x1 , y1 , x2 , y2 , k ))
1344
1344
1345
1345
if y2 - y1 == 0 :
1346
1346
return x2 , y2 + k , x2 , y2 - k
@@ -1353,10 +1353,10 @@ def getpoints(self, x1, y1, x2, y2, k):
1353
1353
b = - 2 * y2
1354
1354
c = y2 ** 2. - k ** 2. * pm ** 2. / (1. + pm ** 2. )
1355
1355
1356
- y3a = (- b + math .sqrt (b ** 2. - 4 * a * c )) / (2. * a )
1356
+ y3a = (- b + math .sqrt (b ** 2 - 4 * a * c )) / (2 * a )
1357
1357
x3a = (y3a - y2 ) / pm + x2
1358
1358
1359
- y3b = (- b - math .sqrt (b ** 2. - 4 * a * c )) / (2. * a )
1359
+ y3b = (- b - math .sqrt (b ** 2 - 4 * a * c )) / (2 * a )
1360
1360
x3b = (y3b - y2 ) / pm + x2
1361
1361
return x3a , y3a , x3b , y3b
1362
1362
@@ -2849,10 +2849,10 @@ def connect(self, posA, posB):
2849
2849
x1 , y1 = posA
2850
2850
x2 , y2 = posB
2851
2851
2852
- cosA , sinA = ( math .cos (self .angleA / 180. * math . pi ),
2853
- math .sin (self .angleA / 180. * math . pi ))
2854
- cosB , sinB = ( math .cos (self .angleB / 180. * math . pi ),
2855
- math .sin (self .angleB / 180. * math . pi ))
2852
+ cosA = math .cos (math . radians ( self .angleA ))
2853
+ sinA = math .sin (math . radians ( self .angleA ))
2854
+ cosB = math .cos (math . radians ( self .angleB ))
2855
+ sinB = math .sin (math . radians ( self .angleB ))
2856
2856
2857
2857
cx , cy = get_intersection (x1 , y1 , cosA , sinA ,
2858
2858
x2 , y2 , cosB , sinB )
@@ -2894,10 +2894,10 @@ def connect(self, posA, posB):
2894
2894
x1 , y1 = posA
2895
2895
x2 , y2 = posB
2896
2896
2897
- cosA , sinA = ( math .cos (self .angleA / 180. * math . pi ),
2898
- math .sin (self .angleA / 180. * math . pi ))
2899
- cosB , sinB = ( math .cos (self .angleB / 180. * math . pi ),
2900
- math .sin (self .angleB / 180. * math . pi ))
2897
+ cosA = math .cos (math . radians ( self .angleA ))
2898
+ sinA = math .sin (math . radians ( self .angleA ))
2899
+ cosB = math .cos (math . radians ( self .angleB ))
2900
+ sinB = math .sin (math . radians ( self .angleB ))
2901
2901
2902
2902
cx , cy = get_intersection (x1 , y1 , cosA , sinA ,
2903
2903
x2 , y2 , cosB , sinB )
@@ -2970,17 +2970,17 @@ def connect(self, posA, posB):
2970
2970
codes = [Path .MOVETO ]
2971
2971
2972
2972
if self .armA :
2973
- cosA = math .cos (self .angleA / 180. * math . pi )
2974
- sinA = math .sin (self .angleA / 180. * math . pi )
2973
+ cosA = math .cos (math . radians ( self .angleA ) )
2974
+ sinA = math .sin (math . radians ( self .angleA ) )
2975
2975
# x_armA, y_armB
2976
2976
d = self .armA - self .rad
2977
2977
rounded .append ((x1 + d * cosA , y1 + d * sinA ))
2978
2978
d = self .armA
2979
2979
rounded .append ((x1 + d * cosA , y1 + d * sinA ))
2980
2980
2981
2981
if self .armB :
2982
- cosB = math .cos (self .angleB / 180. * math . pi )
2983
- sinB = math .sin (self .angleB / 180. * math . pi )
2982
+ cosB = math .cos (math . radians ( self .angleB ) )
2983
+ sinB = math .sin (math . radians ( self .angleB ) )
2984
2984
x_armB , y_armB = x2 + self .armB * cosB , y2 + self .armB * sinB
2985
2985
2986
2986
if rounded :
@@ -3067,18 +3067,10 @@ def connect(self, posA, posB):
3067
3067
armA , armB = self .armA , self .armB
3068
3068
3069
3069
if self .angle is not None :
3070
- #angle = self.angle % 180.
3071
- #if angle < 0. or angle > 180.:
3072
- # angle
3073
- #theta0 = (self.angle%180.)/180.*math.pi
3074
- theta0 = self .angle / 180. * math .pi
3075
- #theta0 = (((self.angle+90)%180.) - 90.)/180.*math.pi
3070
+ theta0 = np .deg2rad (self .angle )
3076
3071
dtheta = theta1 - theta0
3077
3072
dl = dd * math .sin (dtheta )
3078
-
3079
3073
dL = dd * math .cos (dtheta )
3080
-
3081
- #x2, y2 = x2 + dl*ddy, y2 - dl*ddx
3082
3074
x2 , y2 = x1 + dL * math .cos (theta0 ), y1 + dL * math .sin (theta0 )
3083
3075
3084
3076
armB = armB - dl
@@ -3336,8 +3328,8 @@ def _get_arrow_wedge(self, x0, y0, x1, y1,
3336
3328
3337
3329
def transmute (self , path , mutation_size , linewidth ):
3338
3330
3339
- head_length , head_width = self .head_length * mutation_size , \
3340
- self .head_width * mutation_size
3331
+ head_length = self .head_length * mutation_size
3332
+ head_width = self .head_width * mutation_size
3341
3333
head_dist = math .sqrt (head_length ** 2 + head_width ** 2 )
3342
3334
cos_t , sin_t = head_length / head_dist , head_width / head_dist
3343
3335
@@ -3346,8 +3338,7 @@ def transmute(self, path, mutation_size, linewidth):
3346
3338
x1 , y1 = path .vertices [1 ]
3347
3339
3348
3340
# If there is no room for an arrow and a line, then skip the arrow
3349
- has_begin_arrow = (self .beginarrow and
3350
- not ((x0 == x1 ) and (y0 == y1 )))
3341
+ has_begin_arrow = self .beginarrow and not (x0 == x1 and y0 == y1 )
3351
3342
if has_begin_arrow :
3352
3343
verticesA , codesA , ddxA , ddyA = \
3353
3344
self ._get_arrow_wedge (x1 , y1 , x0 , y0 ,
0 commit comments