8000 add method to return determinant of rotational part · RPellowski/spatialmath-python@1cafe6e · GitHub
[go: up one dir, main page]

Skip to content

Commit 1cafe6e

Browse files
committed
add method to return determinant of rotational part
1 parent ac1be8d commit 1cafe6e

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

spatialmath/super_pose.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,38 @@ def ishom2(self):
259259

260260
#----------------------- functions
261261

262+
def det(self):
263+
"""
264+
Determinant of rotational component (superclass method)
265+
266+
:return: Determinant of rotational component
267+
:rtype: float or NumPy array
268+
269+
``x.det()`` is the determinant of the rotation component of the values
270+
of ``x``.
271+
272+
Example::
273+
>>> x=SE3.Rand()
274+
>>> x.det()
275+
1.0000000000000004
276+
>>> x=SE3.Rand(N=2)
277+
>>> x.det()
278+
[0.9999999999999997, 1.0000000000000002]
279+
280+
:SymPy: not supported
281+
"""
282+
if type(self).__name__ in ('SO3', 'SE3'):
283+
if len(self) == 1:
284+
return np.linalg.det(self.A[:3,:3])
285+
else:
286+
return [np.linalg.det(T[:3,:3]) for T in self.data]
287+
elif type(self).__name__ in ('SO2', 'SE2'):
288+
if len(self) == 1:
289+
return np.linalg.det(self.A[:2,:2])
290+
else:
291+
return [np.linalg.det(T[:2,:2]) for T in self.data]
292+
293+
262294
def log(self, twist=False):
263295
"""
264296
Logarithm of pose (superclass method)

0 commit comments

Comments
 (0)
0