some changes
This commit is contained in:
parent
7973718285
commit
3a027799d1
@ -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).
|
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.
|
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
|
||||||
@ -81,10 +81,6 @@ def rot_3D(angle: float, axis: str) -> List[List[float]]:
|
|||||||
:param axis: x,y,z axis of rotation matrix
|
:param axis: x,y,z axis of rotation matrix
|
||||||
:return: 3D 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))
|
cos = math.cos(math.radians(angle))
|
||||||
sin = math.sin(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__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
print(rot_3D(90, "x"))
|
print(rot_3D(-90, "x"))
|
||||||
|
print(transpose([
|
||||||
|
[1, 2, 3],
|
||||||
|
[4, 5, 6]
|
||||||
|
]))
|
||||||
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "matrixmania_marcel"
|
name = "matrixmania_marcel"
|
||||||
version = "0.1.1"
|
version = "0.2.0"
|
||||||
description = "MatrixMania: Simple linear algebra functions for teaching (matmul, transpose, rot_2D)."
|
description = "MatrixMania: Simple linear algebra functions for teaching (matmul, transpose, rot_2D)."
|
||||||
|
|
||||||
authors = [
|
authors = [
|
||||||
|
|||||||
@ -5,5 +5,7 @@ def test_rot_3D():
|
|||||||
result = rot_3D(angle,"x")
|
result = rot_3D(angle,"x")
|
||||||
print(f"Angle:{angle} Rot-Matrix:{result}")
|
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]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1 +1,10 @@
|
|||||||
from matrixmania import transpose
|
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]]
|
||||||
Loading…
x
Reference in New Issue
Block a user