Skip to content

Commit 2fa2056

Browse files
committed
add .Tx and .Ty class methods for constructing pure translational SE2
1 parent 0361004 commit 2fa2056

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

spatialmath/pose2d.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,55 @@ def Exp(cls, S, check=True): # pylint: disable=arguments-differ
397397
return cls([tr.trexp2(s) for s in S])
398398
else:
399399
return cls(tr.trexp2(S), check=False)
400+
@classmethod
401+
def Tx(cls, x):
402+
"""
403+
Create an SE(2) translation along the X-axis
404+
405+
:param x: translation distance along the X-axis
406+
:type x: float
407+
:return: SE(2) matrix
408+
:rtype: SE2 instance
409+
410+
`SE2.Tx(x)` is an SE(2) translation of ``x`` along the x-axis
411+
412+
Example:
413+
414+
.. runblock:: pycon
415+
416+
>>> SE2.Tx(2)
417+
>>> SE2.Tx([2,3])
418+
419+
420+
:seealso: :func:`~spatialmath.base.transforms3d.transl`
421+
:SymPy: supported
422+
"""
423+
return cls([base.transl2(_x, 0) for _x in base.getvector(x)], check=False)
424+
425+
426+
@classmethod
427+
def Ty(cls, y):
428+
"""
429+
Create an SE(2) translation along the Y-axis
430+
431+
:param y: translation distance along the Y-axis
432+
:type y: float
433+
:return: SE(2) matrix
434+
:rtype: SE2 instance
435+
436+
`SE2.Ty(y) is an SE(2) translation of ``y`` along the y-axis
437+
438+
Example:
439+
440+
.. runblock:: pycon
441+
442+
>>> SE2.Ty(2)
443+
>>> SE2.Ty([2,3])
444+
445+
:seealso: :func:`~spatialmath.base.transforms3d.transl`
446+
:SymPy: supported
447+
"""
448+
return cls([base.transl2(0, _y) for _y in base.getvector(y)], check=False)
400449

401450
@staticmethod
402451
def isvalid(x, check=True):

0 commit comments

Comments
 (0)