ordnerstruktur hinzugefügt
This commit is contained in:
1 parent
9c0a02b425
commit
cbbe92c5ee
4 files changed
+56
No files matched your search
File renamed without changes.
@@ -98,6 +98,62 @@ def rot_2D(m: Matrix | float) -> Matrix:
|
|||||||
return [[m[row][col] for row in reversed(range(rows))] for col in range(cols)]
|
return [[m[row][col] for row in reversed(range(rows))] for col in range(cols)]
|
||||||
|
|
||||||
|
|
||||||
|
def rot_3D(angle: float, axis: str) -> list[list[float]]:
|
||||||
|
"""Gibt die Rotationsmatrix für eine Drehung um eine Achse im 3D-Raum zurück.
|
||||||
|
|
||||||
|
Die Drehung erfolgt im rechtshändigen Koordinatensystem um den Winkel
|
||||||
|
``angle`` (in Bogenmaß) um die angegebene Achse.
|
||||||
|
|
||||||
|
Formeln (rechtshändiges Koordinatensystem):
|
||||||
|
Rotation um x-Achse:
|
||||||
|
[[1, 0, 0],
|
||||||
|
[0, cos(a), -sin(a)],
|
||||||
|
[0, sin(a), cos(a)]]
|
||||||
|
Rotation um y-Achse:
|
||||||
|
[[ cos(a), 0, sin(a)],
|
||||||
|
[ 0, 1, 0],
|
||||||
|
[-sin(a), 0, cos(a)]]
|
||||||
|
Rotation um z-Achse:
|
||||||
|
[[cos(a), -sin(a), 0],
|
||||||
|
[sin(a), cos(a), 0],
|
||||||
|
[0, 0, 1]]
|
||||||
|
|
||||||
|
Args:
|
||||||
|
angle: Drehwinkel in Bogenmaß.
|
||||||
|
axis: Drehachse, muss ``'x'``, ``'y'`` oder ``'z'`` sein.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
3x3-Rotationsmatrix.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ValueError: Wenn ``axis`` kein gültiger Achsenwert ist.
|
||||||
|
"""
|
||||||
|
theta = float(angle)
|
||||||
|
c = math.cos(theta)
|
||||||
|
s = math.sin(theta)
|
||||||
|
|
||||||
|
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("Achse muss 'x', 'y' oder 'z' sein.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Whitespace-only changes.
Whitespace-only changes.
Reference in new issue
Block a user