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