From 18ca855c76ac6bca3c56e6586404f93afdf1aa9f Mon Sep 17 00:00:00 2001 From: Lena Date: Wed, 28 Oct 2026 19:38:27 +0100 Subject: [PATCH] =?UTF-8?q?rot=5F2D=20hat=20jetzt=20Winkel=20im=20Bogenma?= =?UTF-8?q?=C3=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compute.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/compute.py b/compute.py index b4d33a3..b8de532 100644 --- a/compute.py +++ b/compute.py @@ -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