dfki-ric / pytransform3d

3D transformations for Python.
https://dfki-ric.github.io/pytransform3d/
Other
618 stars 65 forks source link

[WIP] Fix check of det of rotation matrix #219

Closed AlexanderFabisch closed 1 year ago

AlexanderFabisch commented 1 year ago

Fixes #218

Numerical error of the determinant is (only a bit) larger than the error in individual components of the rotation matrix multiplied with its transpose.

def test_rotation_matrix_precision_error():
    R = pr.active_matrix_from_extrinsic_roll_pitch_yaw([0.5, 0.5, 0.5])
    for _ in range(40):
        R = R.dot(R)
        det_error = abs(1.0 - np.linalg.det(R))
        RRT_error = np.max(R.dot(R.T) - np.eye(3))
        assert RRT_error <= det_error

Hence, we don't have to check whether det(R) is 1. We just have to check for reflection.