Skip to content

Commit

Permalink
Fix isR to catch reflections. (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
myeatman-bdai authored Dec 6, 2023
1 parent 423b781 commit 84614a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spatialmath/base/transformsNd.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def isR(R: NDArray, tol: float = 20) -> bool: # -> TypeGuard[SOnArray]:
"""
return bool(
np.linalg.norm(R @ R.T - np.eye(R.shape[0])) < tol * _eps
and np.linalg.det(R @ R.T) > 0
and np.linalg.det(R) > 0
)


Expand Down
8 changes: 8 additions & 0 deletions tests/base/test_transforms3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ def test_checks(self):
nt.assert_equal(isrot(T, True), False)
nt.assert_equal(ishom(T, True), False)

# reflection case
T = np.array([[-1, 0, 0], [0, 1, 0], [0, 0, 1]])
nt.assert_equal(isR(T), False)
nt.assert_equal(isrot(T), True)
nt.assert_equal(ishom(T), False)
nt.assert_equal(isrot(T, True), False)
nt.assert_equal(ishom(T, True), False)

def test_trinv(self):
T = np.eye(4)
nt.assert_array_almost_equal(trinv(T), T)
Expand Down

0 comments on commit 84614a2

Please sign in to comment.