rot_2D hat jetzt Winkel im Bogenmaß

This commit is contained in:
Lena committed 2026-10-28 19:38:27 +01:00
1 parent 0fc2076efc
commit 18ca855c76
1 file changed
+17 -15
+17 -15
View File
@@ -92,25 +92,26 @@ def transpose(matrix: Matrix) -> Matrix:
def rot_2D(theta: float) -> list[list[float]]:
"""Return the 2‑D rotation matrix for angle *theta* in degrees.
"""Return the 2‑D rotation matrix for angle *theta* in radians.
The matrix is
``[[cos(θ), -sin(θ)],
[sin(θ), cos(θ)]]``
where θ is interpreted as a clockwise rotation.
The matrix is
``[[cos(θ), -sin(θ)],
[sin(θ), cos(θ)]]``
where θ is interpreted as a clockwise rotation.
Parameters
----------
theta : float
Rotation angle in degrees (clockwise).
Parameters
----------
theta : float
Rotation angle in radians (clockwise).
Returns
-------
list[list[float]]
2x2 rotation matrix.
Returns
-------
list[list[float]]
2x2 rotation matrix.
"""
import math
rad = math.radians(theta)
# Treat theta as radians directly
rad = theta
cos_t = math.cos(rad)
sin_t = math.sin(rad)
return [[cos_t, -sin_t], [sin_t, cos_t]]
@@ -141,7 +142,8 @@ def rotate(matrix: Matrix, degrees: float) -> Matrix:
return []
n_rows, n_cols = len(matrix), len(matrix[0])
# rotation matrix
r = rot_2D(degrees)
import math
r = rot_2D(math.radians(degrees))
cos_t, sin_t = r[0][0], r[1][0] # cos and sin from 2x2 matrix
# centre of the matrix (half‑index)
c_row = (n_rows - 1) / 2.0