Skip to content

Commit

Permalink
avoid memcpy, reversal in loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
marscher authored and tylerjereddy committed Mar 20, 2021
1 parent a8450f7 commit af9c79d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scipy/spatial/transform/rotation.pyx
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit af9c79d

Please sign in to comment.