Skip to content

Commit 5d1044a

Browse files
committed
Fixed domain errors in acos near identity
1 parent 469b5fa commit 5d1044a

File tree

2 files changed

+105
-109
lines changed

2 files changed

+105
-109
lines changed

spatialmath/base/transforms3d.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,9 @@ def trlog(
13761376
return skew(w * theta)
13771377
else:
13781378
# general case
1379-
theta = math.acos((np.trace(R) - 1) / 2)
1379+
tr = (np.trace(R) - 1) / 2
1380+
# min for inaccuracies near identity yielding trace > 3
1381+
theta = math.acos(min(tr, 1.0))
13801382
st = math.sin(theta)
13811383
if st == 0:
13821384
if twist:

0 commit comments

Comments
 (0)