Skip to content

Commit 636ec35

Browse files
committed
fix bug when called with [x,y]
1 parent 2cb0e2c commit 636ec35

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

‎spatialmath/base/transforms2d.py‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,23 @@ def transl2(x, y=None):
193193
function.
194194
"""
195195

196-
if base.isscalar(x):
196+
if base.isscalar(x) and base.isscalar(y):
197+
# (x, y) -> SE(2)
197198
t = np.r_[x, y]
198-
T = np.identity(3, dtype=t.dtype)
199-
T[:2, 2] = t
200-
return T
201199
elif base.isvector(x, 2):
202-
T = np.identity(3)
203-
T[:2, 2] = base.getvector(x, 2)
204-
return T
200+
# R2 -> SE(2)
201+
t = base.getvector(x, 2)
205202
elif base.ismatrix(x, (3, 3)):
203+
# SE(2) -> R2
206204
return x[:2, 2]
207205
else:
208206
raise ValueError('bad argument')
209207

208+
if t.dtype != 'O':
209+
t = t.astype('float64')
210+
T = np.identity(3, dtype=t.dtype)
211+
T[:2, 2] = t
212+
return T
210213

211214
def ishom2(T, check=False):
212215
"""

0 commit comments

Comments
 (0)