From 3a027799d1e22958acdb6b27f516d9dd7074615a Mon Sep 17 00:00:00 2001 From: marcelbls Date: Thu, 6 Nov 2025 16:56:00 +0100 Subject: [PATCH] some changes --- README.md | 5 +++++ matrixmania/compute.py | 10 +++++----- pyproject.toml | 2 +- tests/test_rot3D.py | 4 +++- tests/test_transpose.py | 9 +++++++++ 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c1bba8d..335504d 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,8 @@ Gibt die Transponierte einer gegebenen Matrix zurück (Zeilen und Spalten werden Erzeugt eine 2D-Rotationsmatrix für einen gegebenen Winkel (in Grad). Diese Matrix kann verwendet werden, um Punkte in der Ebene um den Ursprung zu rotieren. + +**rot_3D(angle, axis):** + +Erzeugt eine 3D-Rotationsmatrix für gegebenen Winkel und der gegebenen Achse. +Achse x, y oder z und Wikel zwischen 0 und 360 \ No newline at end of file diff --git a/matrixmania/compute.py b/matrixmania/compute.py index 3e1c779..7bb5889 100644 --- a/matrixmania/compute.py +++ b/matrixmania/compute.py @@ -81,10 +81,6 @@ def rot_3D(angle: float, axis: str) -> List[List[float]]: :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)) @@ -102,4 +98,8 @@ def rot_3D(angle: float, axis: str) -> List[List[float]]: if __name__ == "__main__": - print(rot_3D(90, "x")) \ No newline at end of file + print(rot_3D(-90, "x")) + print(transpose([ + [1, 2, 3], + [4, 5, 6] + ])) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 4a821f8..da43199 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "matrixmania_marcel" -version = "0.1.1" +version = "0.2.0" description = "MatrixMania: Simple linear algebra functions for teaching (matmul, transpose, rot_2D)." authors = [ diff --git a/tests/test_rot3D.py b/tests/test_rot3D.py index 65d073e..4547361 100644 --- a/tests/test_rot3D.py +++ b/tests/test_rot3D.py @@ -5,5 +5,7 @@ def test_rot_3D(): result = rot_3D(angle,"x") print(f"Angle:{angle} Rot-Matrix:{result}") - assert result == [[1, 0, 0], [0, 6.123233995736766e-17, -1.0], [0, 1.0, 6.123233995736766e-17]] == [[6.123233995736766e-17, -1.0], [1.0, 6.123233995736766e-17]] + assert result == [[1, 0, 0], [0, 6.123233995736766e-17, -1.0], [0, 1.0, 6.123233995736766e-17]] + + diff --git a/tests/test_transpose.py b/tests/test_transpose.py index b73f7bd..ffb20ee 100644 --- a/tests/test_transpose.py +++ b/tests/test_transpose.py @@ -1 +1,10 @@ from matrixmania import transpose + +def test_transpose(): + matrix = [ + [1, 2, 3], + [4, 5, 6] + ] + matrix = transpose(matrix) + + assert matrix == [[1, 4],[2, 5],[3, 6]] \ No newline at end of file