Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7d5f1f4

Browse filesBrowse files
committed
unit method moved to Twist3/Twist2
1 parent 999697e commit 7d5f1f4
Copy full SHA for 7d5f1f4

File tree

Expand file treeCollapse file tree

1 file changed

+23
-20
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-20
lines changed

‎spatialmath/twist.py

Copy file name to clipboardExpand all lines: spatialmath/twist.py
+23-20Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -163,26 +163,6 @@ def isunit(self):
163163
return [base.isunitvec(x) for x in self.data]
164164

165165
@property
166-
def unit(self):
167-
"""
168-
Unitize twist (superclass property)
169-
170-
:return: a unit twist
171-
:rtype: Twist3 or Twist2
172-
173-
- ``S.unit()`` is a Twist3 object representing a unit twist aligned with the
174-
Twist ``S``.
175-
176-
Example:
177-
178-
.. runblock:: pycon
179-
180-
>>> from spatialmath import Twist3
181-
>>> S = Twist3([1,2,3,4,5,6])
182-
>>> S.unit()
183-
"""
184-
return Twist3(base.unitvec(self.S))
185-
186166
def theta(self):
187167
"""
188168
Twist angle (superclass method)
@@ -752,6 +732,29 @@ def _twist(x, y, z, r):
752732

753733
# ------------------------- methods -------------------------------#
754734

735+
def unit(self):
736+
"""
737+
Unit twist
738+
739+
- ``S.unit()`` is a Twist2 objec3 representing a unit twist aligned with the
740+
Twist ``S``.
741+
742+
Example:
743+
744+
.. runblock:: pycon
745+
746+
>>> from spatialmath import SE3, Twist3
747+
>>> T = SE3(1, 2, 0.3)
748+
>>> S = Twist3(T)
749+
>>> S.unit()
750+
"""
751+
if base.iszerovec(self.w):
752+
# rotational twist
753+
return Twist3(self.S / base.norm(S.w))
754+
else:
755+
# prismatic twist
756+
return Twist3(base.unitvec(self.v), [0, 0, 0])
757+
755758
def ad(self):
756759
"""
757760
Logarithm of adjoint of 3D twist

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.