Skip to content

Commit 6aabcbd

Browse files
committed
allow Twist classes to perform scalar * and /
1 parent 76a33e1 commit 6aabcbd

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

spatialmath/twist.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ def __ne__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argu
280280
raise TypeError('operands to != are of different types')
281281
return left.binop(right, lambda x, y: not all(x == y), list1=False)
282282

283+
def __truediv__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argument
284+
if base.isscalar(right):
285+
return Twist3(left.S / right)
286+
else:
287+
raise ValueError('Twist /, incorrect right operand')
288+
283289
# ======================================================================== #
284290

285291

@@ -1062,7 +1068,7 @@ def __rmul__(right, left): # lgtm[py/not-named-self] pylint: disable=no-self-ar
10621068
- ``s * X`` performs elementwise multiplication of the elements of ``X`` by ``s``
10631069
"""
10641070
if base.isscalar(left):
1065-
return Twist3(self.S * left)
1071+
return Twist3(right.S * left)
10661072
else:
10671073
raise ValueError('Twist3 *, incorrect left operand')
10681074

0 commit comments

Comments
 (0)