File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ def fillpositive(xyz, w2_thresh=None):
42
42
xyz : iterable
43
43
iterable containing 3 values, corresponding to quaternion x, y, z
44
44
w2_thresh : None or float, optional
45
- threshold to determine if w squared is really negative .
45
+ threshold to determine if w squared is non-zero .
46
46
If None (default) then w2_thresh set equal to
47
47
``-np.finfo(xyz.dtype).eps``, if possible, otherwise
48
48
``-np.finfo(np.float64).eps``
@@ -95,11 +95,11 @@ def fillpositive(xyz, w2_thresh=None):
95
95
# Use maximum precision
96
96
xyz = np .asarray (xyz , dtype = MAX_FLOAT )
97
97
# Calculate w
98
- w2 = 1.0 - np .dot (xyz , xyz )
99
- if w2 < 0 :
100
- if w2 < w2_thresh :
101
- raise ValueError (f'w2 should be positive, but is { w2 :e} ' )
98
+ w2 = 1.0 - xyz @ xyz
99
+ if np .abs (w2 ) < np .abs (w2_thresh ):
102
100
w = 0
101
+ elif w2 < 0 :
102
+ raise ValueError (f'w2 should be positive, but is { w2 :e} ' )
103
103
else :
104
104
w = np .sqrt (w2 )
105
105
return np .r_ [w , xyz ]
You can’t perform that action at this time.
0 commit comments