File tree Expand file tree Collapse file tree 2 files changed +29
-9
lines changed Expand file tree Collapse file tree 2 files changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -398,7 +398,7 @@ def iseye(S, tol=10):
398
398
s = S .shape
399
399
if len (s ) != 2 or s [0 ] != s [1 ]:
400
400
return False # not a square matrix
401
- return base .norm (S - np .eye (s [0 ])) < tol * _eps
401
+ return np . linalg .norm (S - np .eye (s [0 ])) < tol * _eps
402
402
403
403
404
404
# ---------------------------------------------------------------------------------------#
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ def isunitvec(v, tol=10):
216
216
>>> isunitvec([1, 0])
217
217
>>> isunitvec([1, 2])
218
218
219
- :seealso: unit, isunittwist
219
+ :seealso: unit, iszerovec, isunittwist
220
220
"""
221
221
return abs (np .linalg .norm (v ) - 1 ) < tol * _eps
222
222
@@ -235,13 +235,33 @@ def iszerovec(v, tol=10):
235
235
.. runblock:: pycon
236
236
237
237
>>> from spatialmath.base import *
238
- >>> isunit ([0, 0])
239
- >>> isunit ([1, 2])
238
+ >>> iszerovec ([0, 0])
239
+ >>> iszerovec ([1, 2])
240
240
241
- :seealso: unit, isunittwist
241
+ :seealso: unit, isunitvec, isunittwist
242
242
"""
243
243
return np .linalg .norm (v ) < tol * _eps
244
244
245
+ def iszero (v , tol = 10 ):
246
+ """
247
+ Test if scalar is zero
248
+
249
+ :param v: value to test
250
+ :type v: float
251
+ :param tol: tolerance in units of eps
252
+ :type tol: float
253
+ :return: whether value is zero
254
+ :rtype: bool
255
+
256
+ .. runblock:: pycon
257
+
258
+ >>> from spatialmath.base import *
259
+ >>> iszero(0)
260
+ >>> iszero(1)
261
+
262
+ :seealso: unit, iszerovec, isunittwist
263
+ """
264
+ return abs (v ) < tol * _eps
245
265
246
266
def isunittwist (v , tol = 10 ):
247
267
r"""
@@ -430,10 +450,10 @@ def unittwist2(S):
430
450
v = S [0 :2 ]
431
451
w = S [2 ]
432
452
433
- if iszerovec (w ):
453
+ if iszero (w ):
434
454
th = norm (v )
435
455
else :
436
- th = norm (w )
456
+ th = abs (w )
437
457
438
458
return S / th
439
459
@@ -463,10 +483,10 @@ def unittwist2_norm(S):
463
483
v = S [0 :2 ]
464
484
w = S [2 ]
465
485
466
- if iszerovec (w ):
486
+ if iszero (w ):
467
487
th = norm (v )
468
488
else :
469
- th = norm (w )
489
+ th = abs (w )
470
490
471
491
return (S / th , th )
472
492
You can’t perform that action at this time.
0 commit comments