37 lines
647 B
Python
37 lines
647 B
Python
|
|
import math
|
|
|
|
import pytest
|
|
|
|
from matrixmania.compute import rot_2D, rot_3D
|
|
|
|
|
|
def test_rot_2D():
|
|
# Arrange
|
|
angle = math.pi / 2
|
|
expected = [[0.0, -1.0], [1.0, 0.0]]
|
|
|
|
# Act
|
|
result = rot_2D(angle)
|
|
|
|
# Assert
|
|
for row, expected_row in zip(result, expected):
|
|
assert row == pytest.approx(expected_row)
|
|
|
|
|
|
def test_rot_3D():
|
|
# Arrange
|
|
angle = math.pi / 2
|
|
expected = [
|
|
[0.0, -1.0, 0.0],
|
|
[1.0, 0.0, 0.0],
|
|
[0.0, 0.0, 1.0],
|
|
]
|
|
|
|
# Act
|
|
result = rot_3D(angle, "z")
|
|
|
|
# Assert
|
|
for row, expected_row in zip(result, expected):
|
|
assert row == pytest.approx(expected_row)
|