diff --git a/scipy/spatial/transform/rotation.pyx b/scipy/spatial/transform/rotation.pyx index fe640762f396..0af9a1ae1765 100644 --- a/scipy/spatial/transform/rotation.pyx +++ b/scipy/spatial/transform/rotation.pyx @@ -176,7 +176,7 @@ cdef double[:, :] _compute_euler_from_matrix( _angles[2] = -atan2(matrix_trans[1, 0] + matrix_trans[0, 1], matrix_trans[0, 0] - matrix_trans[1, 1]) else: - # For instrinsic, set third angle to zero + # For intrinsic, set third angle to zero # 6a if not safe: _angles[2] = 0 @@ -209,16 +209,16 @@ cdef double[:, :] _compute_euler_from_matrix( elif _angles[i] > pi: _angles[i] -= 2 * pi + if extrinsic: + # reversal + _angles[0], _angles[2] = _angles[2], _angles[0] + # Step 8 if not safe: warnings.warn("Gimbal lock detected. Setting third angle to zero " "since it is not possible to uniquely determine " "all angles.") - # Reverse role of extrinsic and intrinsic rotations, but let third angle be - # zero for gimbal locked cases. Take a copy, to enforce contiguous memory layout. - if extrinsic: - angles = angles[:, ::-1].copy() return angles @cython.boundscheck(False)