diff --git a/.idea/MatrixMania.iml b/.idea/MatrixMania.iml
index 51bcf32..3b1d427 100644
--- a/.idea/MatrixMania.iml
+++ b/.idea/MatrixMania.iml
@@ -7,4 +7,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/matrixmania/compute.py b/matrixmania/compute.py
index e9b3c0a..3e1c779 100644
--- a/matrixmania/compute.py
+++ b/matrixmania/compute.py
@@ -74,7 +74,32 @@ def rot_2D(angle: int) -> List[List[float]]:
return [[zahl1, zahl2], [zahl3, zahl4]]
+def rot_3D(angle: float, axis: str) -> List[List[float]]:
+ """
+ Rotation matrix 3D
+ :param angle: between 0 and 360 degrees
+ :param axis: x,y,z axis of rotation matrix
+ :return: 3D rotation matrix
+ """
+ if angle > 360:
+ raise ValueError("angle must be less than 360")
+ elif angle < 0:
+ raise ValueError("angle must be greater than 0")
+
+ cos = math.cos(math.radians(angle))
+ sin = math.sin(math.radians(angle))
+
+ if axis == "x":
+ return [[1,0,0],[0, cos, -sin],[0, sin, cos]]
+ elif axis == "y":
+ return [[cos, 0, sin],[0,1,0],[-sin,0,cos]]
+ elif axis == "z":
+ return [[cos, -sin, 0],[sin, cos, 0],[0, 0, 1]]
+
+ else:
+ raise ValueError("Not a valid axis. Choose from 'x', 'y', 'z'.")
+
if __name__ == "__main__":
- "alles selbst gemacht"
- print(rot_2D())
\ No newline at end of file
+
+ print(rot_3D(90, "x"))
\ No newline at end of file
diff --git a/tests/test_matmul.py b/tests/test_matmul.py
index a56903d..240618e 100644
--- a/tests/test_matmul.py
+++ b/tests/test_matmul.py
@@ -12,4 +12,5 @@ def test_matmul():
matrix_c = matmul(matrix_a, matrix_b)
print(f"Matrix A: {matrix_a} mal Matrix B: {matrix_b} = Matrix C: {matrix_c}")
+ assert matrix_c == [[20, 37, 26], [-1, 27, -8]]
diff --git a/tests/test_rot.py b/tests/test_rot2D.py
similarity index 63%
rename from tests/test_rot.py
rename to tests/test_rot2D.py
index 5c9b55d..3b92cca 100644
--- a/tests/test_rot.py
+++ b/tests/test_rot2D.py
@@ -5,4 +5,6 @@ def test_rot_2D():
result = rot_2D(angle)
print(f"Angle:{angle} Rot-Matrix:{result}")
+ assert result == [[6.123233995736766e-17, -1.0], [1.0, 6.123233995736766e-17]]
+
diff --git a/tests/test_rot3D.py b/tests/test_rot3D.py
new file mode 100644
index 0000000..ad408f3
--- /dev/null
+++ b/tests/test_rot3D.py
@@ -0,0 +1 @@
+from matrixmania import rot_3D
\ No newline at end of file
diff --git a/tests/test_transpose.py b/tests/test_transpose.py
new file mode 100644
index 0000000..b73f7bd
--- /dev/null
+++ b/tests/test_transpose.py
@@ -0,0 +1 @@
+from matrixmania import transpose