Files
matrixmania/test/test_matrixmania/test_rot.py
T

30 lines
733 B
Python

import pytest
from compute import rot_2D, rot_3D
def test_rot_2D_90_degrees():
# Arrange
angle = 90.0
# Act
matrix = rot_2D(angle)
# Assert (bei 90°: cos(90)=0, sin(90)=1)
assert pytest.approx(matrix[0][0], abs=1e-5) == 0.0
assert pytest.approx(matrix[0][1], abs=1e-5) == -1.0
assert pytest.approx(matrix[1][0], abs=1e-5) == 1.0
assert pytest.approx(matrix[1][1], abs=1e-5) == 0.0
def test_rot_3D_z_axis_90_degrees():
# Arrange
angle = 90.0
axis = 'z'
# Act
matrix = rot_3D(angle, axis)
# Assert
assert pytest.approx(matrix[0][0], abs=1e-5) == 0.0
assert pytest.approx(matrix[0][1], abs=1e-5) == -1.0
assert pytest.approx(matrix[2][2], abs=1e-5) == 1.0