Commit 1aeff04b authored by bongjinkoo's avatar bongjinkoo

Fix an error on validate_rotation_matrix().

parent ec778524
Pipeline #1374 failed with stages
in 20 minutes and 56 seconds
......@@ -67,7 +67,8 @@ def validate_rotation_matrix(matrix):
3. Has 3 rows
4. Has 3 columns
5. Is orthogonal, i.e., transpose(matrix) * matrix = identity matrix.
6. Is its determinant positive (+1) (c.f., it is a reflection matrix if the determinant is negative (-1))
6. Is its determinant positive (+1) (c.f., it is a reflection matrix (improper rotation)
if the determinant is negative (-1))
:param matrix: rotation matrix
:raises: TypeError, ValueError if not
......@@ -87,7 +88,7 @@ def validate_rotation_matrix(matrix):
tolerance = 1e-6
id = np.eye(3)
residual = np.absolute(mat) - id
if np.flatnonzero(np.where(residual < -tolerance) & (residual > tolerance)).shape[0] > 0:
if np.flatnonzero(np.where((residual < -tolerance) | (residual > tolerance))).shape[0] > 0:
raise ValueError("Rotation matrix should be orthogonal.")
# Check if the determinant is positive
......
......@@ -104,12 +104,14 @@ def test_rotation_matrix_invalid_because_too_few_columns():
with pytest.raises(ValueError):
vm.validate_rotation_matrix(np.ones((3, 2)))
def test_rotation_matrix_invalid_because_not_orthogonal():
with pytest.raises(ValueError):
vm.validate_rotation_matrix(np.array([[3, -4, 1], [5, 3, -7], [-9, 2, 6]]))
def test_rotation_matrix_valid():
rotation_matrix = np.eye(3)
assert vm.validate_rotation_matrix(rotation_matrix)
def test_translation_matrix_invalid_because_wrong_type():
with pytest.raises(TypeError):
vm.validate_translation_column_vector(1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment