184 lines
3.5 KiB
Python
184 lines
3.5 KiB
Python
from src.compute import rot_2d, rot_3d
|
|
import math
|
|
|
|
def test_rot2d_1():
|
|
|
|
angle = 0
|
|
expected_value = [[1, 0], [0, 1]]
|
|
|
|
result = rot_2d(angle)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot2d_2():
|
|
|
|
angle = math.pi/2
|
|
expected_value = [[0, -1], [1, 0]]
|
|
|
|
result = rot_2d(angle)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot2d_3():
|
|
|
|
angle = math.pi
|
|
expected_value = [[-1, 0], [0, -1]]
|
|
|
|
result = rot_2d(angle)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot2d_4():
|
|
|
|
angle = 3*math.pi/2
|
|
expected_value = [[0, 1], [-1, 0]]
|
|
|
|
result = rot_2d(angle)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot2d_5():
|
|
|
|
angle = 2*math.pi
|
|
expected_value = [[1, 0], [0, 1]]
|
|
|
|
result = rot_2d(angle)
|
|
|
|
assert result == expected_value
|
|
|
|
|
|
def test_rot3d_1x():
|
|
angle = 0
|
|
axis = "x"
|
|
expected_value = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_1y():
|
|
angle = 0
|
|
axis = "y"
|
|
expected_value = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_1z():
|
|
angle = 0
|
|
axis = "z"
|
|
expected_value = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_2x():
|
|
angle = math.pi/2
|
|
axis = "x"
|
|
expected_value = [[1, 0, 0], [0, 0, -1], [0, 1, 0]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_2y():
|
|
angle = math.pi/2
|
|
axis = "y"
|
|
expected_value = [[0, 0, 1], [0, 1, 0], [-1, 0, 0]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_2z():
|
|
angle = math.pi/2
|
|
axis = "z"
|
|
expected_value = [[0, -1, 0], [1, 0, 0], [0, 0, 1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_3x():
|
|
angle = math.pi
|
|
axis = "x"
|
|
expected_value = [[1, 0, 0], [0, -1, 0], [0, 0, -1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_3y():
|
|
angle = math.pi
|
|
axis = "y"
|
|
expected_value = [[-1, 0, 0], [0, 1, 0], [0, 0, -1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_3z():
|
|
angle = math.pi
|
|
axis = "z"
|
|
expected_value = [[-1, 0, 0], [0, -1, 0], [0, 0, 1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_4x():
|
|
angle = 3*math.pi/2
|
|
axis = "x"
|
|
expected_value = [[1, 0, 0], [0, 0, 1], [0, -1, 0]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_4y():
|
|
angle = 3*math.pi/2
|
|
axis = "y"
|
|
expected_value = [[0, 0, -1], [0, 1, 0], [1, 0, 0]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_4z():
|
|
angle = 3*math.pi/2
|
|
axis = "z"
|
|
expected_value = [[0, 1, 0], [-1, 0, 0], [0, 0, 1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_5x():
|
|
angle = 2*math.pi
|
|
axis = "x"
|
|
expected_value = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_5y():
|
|
angle = 2*math.pi
|
|
axis = "y"
|
|
expected_value = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|
|
|
|
def test_rot3d_5z():
|
|
angle = 2*math.pi
|
|
axis = "z"
|
|
expected_value = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
|
|
|
|
result = rot_3d(angle, axis)
|
|
|
|
assert result == expected_value
|