in compute.py: rot_3D Implementiert, für alle 3 Achsen(x,y,z), ValueError für ungültige Achsen
test_rot.py Datei erstellt mit 7 Testläufen (3x rot_2D, 4x rot_3D)
This commit is contained in:
1 parent
754f6bef90
commit
41093db2ad
2 files changed
+141
-1
No files matched your search
+20
-1
@@ -104,7 +104,26 @@ def print_matrix(matrix: Matrix) -> None:
|
||||
"""Print a matrix as a nicely formatted table."""
|
||||
print(tabulate(matrix, tablefmt="grid"))
|
||||
|
||||
def rot_3D(angle: float, axis: str) -> list[list[float]]
|
||||
def rot_3D(angle: float, axis: str) -> list[list[float]]:
|
||||
axis = axis.lower()
|
||||
c, s = cos(angle), sin(angle)
|
||||
|
||||
if axis == "x":
|
||||
return [[1.0, 0.0, 0.0],
|
||||
[0.0, c, -s],
|
||||
[0.0, s, c]]
|
||||
if axis == "y":
|
||||
return [[c, 0.0, s],
|
||||
[0.0, 1.0, 0.0],
|
||||
[-s, 0.0, c]]
|
||||
if axis == "z":
|
||||
return [[c, -s, 0.0],
|
||||
[s, c, 0.0],
|
||||
[0.0, 0.0, 1.0]]
|
||||
|
||||
raise ValueError(f"Invalid axis '{axis}': expected 'x', 'y' or 'z'.")
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user