Add 3D rotation and rotation tests
This commit is contained in:
1 parent
ebfe4630ee
commit
17eff74d0c
4 files changed
+231
No files matched your search
+43
@@ -0,0 +1,43 @@
|
||||
from math import pi
|
||||
|
||||
import pytest
|
||||
|
||||
from compute import rot_2D, rot_3D
|
||||
|
||||
|
||||
def test_rot_2D() -> None:
|
||||
"""Test a 90-degree rotation matrix in 2D."""
|
||||
# Arrange
|
||||
angle = pi / 2
|
||||
expected = [
|
||||
[0.0, -1.0],
|
||||
[1.0, 0.0],
|
||||
]
|
||||
|
||||
# Act
|
||||
result = rot_2D(angle)
|
||||
|
||||
# Assert
|
||||
for i in range(2):
|
||||
for j in range(2):
|
||||
assert result[i][j] == pytest.approx(expected[i][j])
|
||||
|
||||
|
||||
def test_rot_3D() -> None:
|
||||
"""Test a 90-degree rotation matrix around the z-axis."""
|
||||
# Arrange
|
||||
angle = pi / 2
|
||||
axis = "z"
|
||||
expected = [
|
||||
[0.0, -1.0, 0.0],
|
||||
[1.0, 0.0, 0.0],
|
||||
[0.0, 0.0, 1.0],
|
||||
]
|
||||
|
||||
# Act
|
||||
result = rot_3D(angle, axis)
|
||||
|
||||
# Assert
|
||||
for i in range(3):
|
||||
for j in range(3):
|
||||
assert result[i][j] == pytest.approx(expected[i][j])
|
||||
Reference in new issue
Block a user