Skip to content

Commit 84614a2

Browse files
Fix isR to catch reflections. (#110)
1 parent 423b781 commit 84614a2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

spatialmath/base/transformsNd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def isR(R: NDArray, tol: float = 20) -> bool: # -> TypeGuard[SOnArray]:
380380
"""
381381
return bool(
382382
np.linalg.norm(R @ R.T - np.eye(R.shape[0])) < tol * _eps
383-
and np.linalg.det(R @ R.T) > 0
383+
and np.linalg.det(R) > 0
384384
)
385385

386386

tests/base/test_transforms3d.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ def test_checks(self):
6161
nt.assert_equal(isrot(T, True), False)
6262
nt.assert_equal(ishom(T, True), False)
6363

64+
# reflection case
65+
T = np.array([[-1, 0, 0], [0, 1, 0], [0, 0, 1]])
66+
nt.assert_equal(isR(T), False)
67+
nt.assert_equal(isrot(T), True)
68+
nt.assert_equal(ishom(T), False)
69+
nt.assert_equal(isrot(T, True), False)
70+
nt.assert_equal(ishom(T, True), False)
71+
6472
def test_trinv(self):
6573
T = np.eye(4)
6674
nt.assert_array_almost_equal(trinv(T), T)

0 commit comments

Comments
 (0)