@@ -2984,15 +2984,10 @@ def calc_arrows(UVW):
2984
2984
UVW = np .column_stack (input_args [3 :]).astype (float )
2985
2985
2986
2986
# Normalize rows of UVW
2987
- norm = np .linalg .norm (UVW , axis = 1 )
2988
-
2989
- # If any row of UVW is all zeros, don't make a quiver for it
2990
- mask = norm > 0
2991
- XYZ = XYZ [mask ]
2992
2987
if normalize :
2993
- UVW = UVW [ mask ] / norm [ mask ]. reshape (( - 1 , 1 ) )
2994
- else :
2995
- UVW = UVW [ mask ]
2988
+ norm = np . linalg . norm ( UVW , axis = 1 )
2989
+ norm [ norm == 0 ] = 1
2990
+ UVW = UVW / norm . reshape (( - 1 , 1 ))
2996
2991
2997
2992
if len (XYZ ) > 0 :
2998
2993
# compute the shaft lines all at once with an outer product
@@ -3003,10 +2998,13 @@ def calc_arrows(UVW):
3003
2998
heads = shafts [:, :1 ] - np .multiply .outer (arrow_dt , head_dirs )
3004
2999
# stack left and right head lines together
3005
3000
heads = heads .reshape ((len (arrow_dt ), - 1 , 3 ))
3006
- # transpose to get a list of lines
3001
+ # transpose to get a list of lines, n heads x 2 points x 3 dimensions
3007
3002
heads = heads .swapaxes (0 , 1 )
3008
-
3009
- lines = [* shafts , * heads ]
3003
+ # combine into a single line: n heads, 5 points, 3 dimensions
3004
+ lines = np .empty ((len (shafts ), 5 , 3 ), dtype = shafts .dtype )
3005
+ lines [:, 0 :2 ] = shafts [:, ::- 1 ]
3006
+ lines [:, 2 :4 ] = heads [::2 , ::- 1 ]
3007
+ lines [:, 4 ] = heads [1 ::2 , 1 ]
3010
3008
else :
3011
3009
lines = []
3012
3010
0 commit comments