Previously, passing an invalid rotation matrix to the UnitQuaternion constructor would just silently fail and yield an identity quaternion. For example:
>>> R = 1.1 * np.eye(3) # not a valid rotation matrix
>>> UnitQuaternion(R)
1.0000 << 0.0000, 0.0000, 0.0000 >>
Funnily enough, this only happens when check=True, since when check=False the constructor assumes it can try to interpret the argument as a quaternion (i.e., a vector of length 4) and fails.
This PR fixes this problem by adding additional checks against the argument passed to the constructor, and also has a specific check for when the matrix passed is 3x3 but is not a valid rotation matrix.
Previously, passing an invalid rotation matrix to the
UnitQuaternion
constructor would just silently fail and yield an identity quaternion. For example:Funnily enough, this only happens when
check=True
, since whencheck=False
the constructor assumes it can try to interpret the argument as a quaternion (i.e., a vector of length 4) and fails.This PR fixes this problem by adding additional checks against the argument passed to the constructor, and also has a specific check for when the matrix passed is 3x3 but is not a valid rotation matrix.