Skip to content

Commit 3517123

Browse files
committed
allow pre/post mult by conforming numpy array
1 parent d7a1c8f commit 3517123

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

spatialmath/baseposematrix.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,16 +1079,21 @@ def __mul__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-arg
10791079

10801080
elif isinstance(right, (list, tuple, np.ndarray)):
10811081
#print('*: pose x array')
1082-
if len(left) == 1 and base.isvector(right, left.N):
1083-
# pose x vector
1084-
#print('*: pose x vector')
1085-
v = base.getvector(right, out='col')
1086-
if left.isSE:
1087-
# SE(n) x vector
1088-
return base.h2e(left.A @ base.e2h(v))
1082+
if len(left) == 1:
1083+
if base.isvector(right, left.N):
1084+
# pose x vector
1085+
#print('*: pose x vector')
1086+
v = base.getvector(right, out='col')
1087+
if left.isSE:
1088+
# SE(n) x vector
1089+
return base.h2e(left.A @ base.e2h(v))
1090+
else:
1091+
# SO(n) x vector
1092+
return left.A @ v
10891093
else:
1090-
# SO(n) x vector
1091-
return left.A @ v
1094+
if right.shape == left.A.shape:
1095+
# SE(n) x (nxn)
1096+
return left.A @ right
10921097

10931098
elif len(left) > 1 and base.isvector(right, left.N):
10941099
# pose array x vector
@@ -1165,10 +1170,11 @@ def __rmul__(right, left): # lgtm[py/not-named-self] pylint: disable=no-self-ar
11651170
11661171
:seealso: :func:`__mul__`
11671172
"""
1168-
if base.isscalar(left):
1169-
return right.__mul__(left)
1170-
else:
1171-
return NotImplemented
1173+
# if base.isscalar(left):
1174+
# return right.__mul__(left)
1175+
# else:
1176+
# return NotImplemented
1177+
return right.__mul__(left)
11721178

11731179
def __imul__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
11741180
"""

0 commit comments

Comments
 (0)