File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -398,7 +398,7 @@ def iseye(S, tol=10):
398398 s = S .shape
399399 if len (s ) != 2 or s [0 ] != s [1 ]:
400400 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
402402
403403
404404# ---------------------------------------------------------------------------------------#
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ def isunitvec(v, tol=10):
216216 >>> isunitvec([1, 0])
217217 >>> isunitvec([1, 2])
218218
219- :seealso: unit, isunittwist
219+ :seealso: unit, iszerovec, isunittwist
220220 """
221221 return abs (np .linalg .norm (v ) - 1 ) < tol * _eps
222222
@@ -235,13 +235,33 @@ def iszerovec(v, tol=10):
235235 .. runblock:: pycon
236236
237237 >>> from spatialmath.base import *
238- >>> isunit ([0, 0])
239- >>> isunit ([1, 2])
238+ >>> iszerovec ([0, 0])
239+ >>> iszerovec ([1, 2])
240240
241- :seealso: unit, isunittwist
241+ :seealso: unit, isunitvec, isunittwist
242242 """
243243 return np .linalg .norm (v ) < tol * _eps
244244
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
245265
246266def isunittwist (v , tol = 10 ):
247267 r"""
@@ -430,10 +450,10 @@ def unittwist2(S):
430450 v = S [0 :2 ]
431451 w = S [2 ]
432452
433- if iszerovec (w ):
453+ if iszero (w ):
434454 th = norm (v )
435455 else :
436- th = norm (w )
456+ th = abs (w )
437457
438458 return S / th
439459
@@ -463,10 +483,10 @@ def unittwist2_norm(S):
463483 v = S [0 :2 ]
464484 w = S [2 ]
465485
466- if iszerovec (w ):
486+ if iszero (w ):
467487 th = norm (v )
468488 else :
469- th = norm (w )
489+ th = abs (w )
470490
471491 return (S / th , th )
472492
You can’t perform that action at this time.
0 commit comments