MatrixMania/tests/test_rot.py
2025-11-02 22:46:11 +01:00

21 lines
754 B
Python

from matrixmania.compute import rot_2D
import math
def test_rot_2D_identity():
"""Rotation by 0 radians should return identity matrix"""
result = rot_2D(0)
expected = [[1, 0], [0, 1]]
assert all(abs(result[i][j] - expected[i][j]) < 1e-9 for i in range(2) for j in range(2))
def test_rot_2D_90_degrees():
"""Rotation by 90° (pi/2 radians)"""
result = rot_2D(math.pi / 2)
expected = [[0, -1], [1, 0]]
assert all(abs(result[i][j] - expected[i][j]) < 1e-9 for i in range(2) for j in range(2))
def test_rot_2D_180_degrees():
"""Rotation by 180° (pi radians)"""
result = rot_2D(math.pi)
expected = [[-1, 0], [0, -1]]
assert all(abs(result[i][j] - expected[i][j]) < 1e-9 for i in range(2) for j in range(2))