Skip to content

Commit 7405507

Browse files
committed
Add Trans class method for pure translation
1 parent 663b04f commit 7405507

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

spatialmath/pose3d.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,16 +1463,43 @@ def Delta(cls, d):
14631463
:rtype: SE3 instance
14641464
14651465
1466-
``T = delta2tr(d)`` is an SE(3) representing differential
1466+
``SE3.Delta2tr(d)`` is an SE(3) representing differential
14671467
motion :math:`d = [\delta_x, \delta_y, \delta_z, \theta_x, \theta_y, \theta_z]`.
14681468
14691469
:Reference: Robotics, Vision & Control: Second Edition, P. Corke, Springer 2016; p67.
14701470
1471-
:seealso: :func:`~delta`, :func:`~spatialmath.base.transform3d.delta2tr`
1471+
:seealso: :meth:`~delta` :func:`~spatialmath.base.transform3d.delta2tr`
14721472
:SymPy: supported
14731473
"""
14741474
return cls(base.trnorm(base.delta2tr(d)))
14751475

1476+
@classmethod
1477+
def Trans(cls, x, y=None, z=None):
1478+
"""
1479+
Create SE(3) from translation vector
1480+
1481+
:param x: x-coordinate or translation vector
1482+
:type x: float or array_like(3)
1483+
:param y: y-coordinate, defaults to None
1484+
:type y: float, optional
1485+
:param z: z-coordinate, defaults to None
1486+
:type z: float, optional
1487+
:return: SE(3) matrix
1488+
:rtype: SE3 instance
1489+
1490+
``T = SE3.Trans(x, y, z)`` is an SE(3) representing pure translation.
1491+
1492+
``T = SE3.Trans([x, y, z])`` as above, but translation is given as an
1493+
array.
1494+
1495+
"""
1496+
if y is None and z is None:
1497+
# single passed value, assume is 3-vector
1498+
t = base.getvector(x, 3)
1499+
else:
1500+
t = np.array([x, y, z])
1501+
return cls(t)
1502+
14761503
@classmethod
14771504
def Tx(cls, x):
14781505
"""
@@ -1573,7 +1600,7 @@ def Rt(cls, R, t=None, check=True):
15731600
if t is None:
15741601
t = np.zeros((3,))
15751602
return cls(base.rt2tr(R, t, check=check), check=check)
1576-
1603+
15771604
def angdist(self, other, metric=6):
15781605
r"""
15791606
Angular distance metric between poses

0 commit comments

Comments
 (0)