8000 Add Tx, Ty, Tz constructors for Twist · VB6Hobbyst7/spatialmath-python@cf15861 · GitHub
[go: up one dir, main page]

Skip to content

Commit cf15861

Browse files
committed
Add Tx, Ty, Tz constructors for Twist
1 parent fc3d9a2 commit cf15861

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

spatialmath/twist.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,80 @@ def Rz(cls, theta, unit='rad', t=None):
631631
:SymPy: supported
632632
"""
633633
return cls([np.r_[0,0,0,0,0,x] for x in base.getunit(theta, unit=unit)])
634+
@classmethod
635+
def Tx(cls, x):
636+
"""
637+
Create a new 3D twist for pure translation along the X-axis
638+
639+
:param x: translation distance along the X-axis
640+
:type x: float
641+
:return: 3D twist vector
642+
:rtype: Twist3 instance
643+
644+
`Twist3.Tx(x)` is an se(3) translation of ``x`` along the x-axis
645+
646+
Example:
647+
648+
.. runblock:: pycon
649+
650+
>>> Twist3.Tx(2)
651+
>>> Twist3.Tx([2,3])
652+
653+
654+
:seealso: :func:`~spatialmath.base.transforms3d.transl`
655+
:SymPy: supported
656+
"""
657+
return cls([base.transl(_x, 0, 0) for _x in base.getvector(x)], check=False)
658+
659+
660+
@classmethod
661+
def Ty(cls, y):
662+
"""
663+
Create a new 3D twist for pure translation along the Y-axis
664+
665+
:param y: translation distance along the Y-axis
666+
:type y: float
667+
:return: 3D twist vector
668+
:rtype: Twist3 instance
669+
670+
`Twist3.Ty(y) is an se(3) translation of ``y`` along the y-axis
671+
672+
Example:
673+
674+
.. runblock:: pycon
675+
676+
>>> Twist3.Ty(2)
677+
>>> Twist3.Ty([2, 3])
678+
679+
680+
:seealso: :func:`~spatialmath.base.transforms3d.transl`
681+
:SymPy: supported
682+
"""
683+
return cls([base.transl(0, _y, 0) for _y in base.getvector(y)], check=False)
684+
685+
@classmethod
686+
def Tz(cls, z):
687+
"""
688+
Create a new 3D twist for pure translation along the Z-axis
689+
690+
:param z: translation distance along the Z-axis
691+
:type z: float
692+
:return: 3D twist vector
693+
:rtype: Twist3 instance
694+
695+
`Twist3.Tz(z)` is an se(3) translation of ``z`` along the z-axis
696+
697+
Example:
698+
699+
.. runblock:: pycon
700+
701+
>>> Twist3.Tz(2)
702+
>>> Twist3.Tz([2, 3])
703+
704+
:seealso: :func:`~spatialmath.base.transforms3d.transl`
705+
:SymPy: supported
706+
"""
707+
return cls([base.transl(0, 0, _z) for _z in base.getvector(z)], check=False)
634708

635709
@classmethod
636710
def Rand(cls, *, xrange=(-1, 1), yrange=(-1, 1), zrange=(-1, 1), N=1): # pylint: disable=arguments-differ

0 commit comments

Comments
 (0)
0