Skip to content

Commit 52c763e

Browse files
committed
pitch, pole, theta are now properties
unit is a method
1 parent 359c280 commit 52c763e

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

spatialmath/twist.py

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ def se3(self):
861861
else:
862862
return [base.skewa(x.S) for x in self]
863863

864+
@property
864865
def pitch(self):
865866
"""
866867
Pitch of a 3D twist
@@ -882,7 +883,7 @@ def pitch(self):
882883
>>> from spatialmath import SE3, Twist3
883884
>>> T = SE3(1, 2, 3) * SE3.Rx(0.3)
884885
>>> S = Twist3(T)
885-
>>> S.pitch()
886+
>>> S.pitch
886887
887888
"""
888889
return np.dot(self.w, self.v)
@@ -905,8 +906,9 @@ def line(self):
905906
>>> S = Twist3(T)
906907
>>> S.line()
907908
"""
908-
return Line3([Line3(-tw.v - tw.pitch() * tw.w, tw.w) for tw in self])
909+
return Line3([Line3(-tw.v - tw.pitch * tw.w, tw.w) for tw in self])
909910

911+
@property
910912
def pole(self):
911913
"""
912914
Pole of a 3D twist
@@ -924,9 +926,9 @@ def pole(self):
924926
>>> from spatialmath import SE3, Twist3
925927
>>> T = SE3(1, 2, 3) * SE3.Rx(0.3)
926928
>>> S = Twist3(T)
927-
>>> S.pole()
929+
>>> S.pole
928930
"""
929-
return np.cross(self.w, self.v) / self.theta()
931+
return np.cross(self.w, self.v) / self.theta
930932

931933
def theta(self):
932934
"""
@@ -1374,9 +1376,35 @@ def w(self):
13741376
"""
13751377
return self.data[0][2]
13761378

1379+
@property
1380+
def pole(self):
1381+
"""
1382+
Pole of a 2D twist
1383+
1384+
:return: the pole of the twist
1385+
:rtype: ndarray(2)
1386+
1387+
``X.pole()`` is a point on the twist axis. For a pure translation
1388+
this point is at infinity.
1389+
1390+
Example:
1391+
1392+
.. runblock:: pycon
1393+
1394+
>>> from spatialmath import SE3, Twist3
1395+
>>> T = SE2(1, 2, 0.3)
1396+
>>> S = Twist2(T)
1397+
>>> S.pole()
1398+
"""
1399+
p = np.cross(np.r_[0, 0, self.w], np.r_[self.v, 0]) / self.theta
1400+
return p[:2]
1401+
13771402
# ------------------------- methods -------------------------------#
13781403

1379-
def SE2(self):
1404+
def printline(self):
1405+
return self.SE2().printline()
1406+
1407+
def SE2(self, theta=1):
13801408
"""
13811409
Convert 2D twist to SE(2) matrix
13821410
@@ -1471,29 +1499,7 @@ def exp(self, theta=None, unit='rad'):
14711499
else:
14721500
return SE2([base.trexp2(self.S * t) for t in theta])
14731501

1474-
def pole(self):
1475-
"""
1476-
Pole of a 2D twist
1477-
1478-
:return: the pole of the twist
1479-
:rtype: ndarray(2)
1480-
1481-
``X.pole()`` is a point on the twist axis. For a pure translation
1482-
this point is at infinity.
14831502

1484-
Example:
1485-
1486-
.. runblock:: pycon
1487-
1488-
>>> from spatialmath import SE3, Twist3
1489-
>>> T = SE2(1, 2, 0.3)
1490-
>>> S = Twist2(T)
1491-
>>> S.pole()
1492-
"""
1493-
p = np.cross(np.r_[0, 0, self.w], np.r_[self.v, 0]) / self.theta()
1494-
return p[:2]
1495-
1496-
@property
14971503
def unit(self):
14981504
"""
14991505
Unit twist

0 commit comments

Comments
 (0)