cleanup
This commit is contained in:
1 parent
e02b552da3
commit
ddaceeaffe
2 files changed
+6
-9
No files matched your search
@@ -103,17 +103,12 @@ def transpose(matrix: Matrix) -> list[list[float]]:
|
|||||||
Alle Zeilen werden zu Spalten und alle Spalten zu Zeilen.
|
Alle Zeilen werden zu Spalten und alle Spalten zu Zeilen.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
|
||||||
matrix
|
matrix
|
||||||
Matrix in Form ``Sequence[Sequence[float]]``.
|
Matrix in Form ``Sequence[Sequence[float]]``.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
|
||||||
list[list[float]]
|
list[list[float]]
|
||||||
Die transponierte Matrix.
|
Die transponierte Matrix.
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
------
|
|
||||||
ValueError
|
ValueError
|
||||||
Wenn ``matrix`` leer ist oder nicht gleichmäßig viele Spalten
|
Wenn ``matrix`` leer ist oder nicht gleichmäßig viele Spalten
|
||||||
in den Zeilen hat.
|
in den Zeilen hat.
|
||||||
@@ -167,8 +162,6 @@ if __name__ == "__main__":
|
|||||||
print("example 3 passed:", error)
|
print("example 3 passed:", error)
|
||||||
|
|
||||||
|
|
||||||
# end of main guard
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -25,18 +25,22 @@ BLUE = (0, 0, 255)
|
|||||||
|
|
||||||
|
|
||||||
class Moon(Game):
|
class Moon(Game):
|
||||||
"""Demonstrates a moon orbiting the Earth using matrix rotation."""
|
|
||||||
|
|
||||||
def __init__(self, title: str = "Moon", fps: int = 60, size: Tuple[int, int] = (640, 400)) -> None:
|
def __init__(self, title: str = "Moon", fps: int = 60, size: Tuple[int, int] = (640, 400)) -> None:
|
||||||
super().__init__(title, fps, size)
|
super().__init__(title, fps, size)
|
||||||
# Earth centre – centre of the window
|
# Earth centre – centre of the window
|
||||||
self.center: Tuple[int, int] = (size[0] // 2, size[1] // 2)
|
self.center: Tuple[int, int] = (size[0] // 2, size[1] // 2)
|
||||||
# Fixed orbit offset from the centre
|
# Fixed orbit offset from the centre
|
||||||
self.offset: Tuple[float, float] = (100.0, 0.0)
|
self.offset: Tuple[float, float] = (150.0, 0.0)
|
||||||
# Angular speed (radians per frame)
|
# Angular speed (radians per frame)
|
||||||
self.delta_theta: float = 0.01
|
self.delta_theta: float = 0.01
|
||||||
self.theta: float = 0.0
|
self.theta: float = 0.0
|
||||||
self.rot_moon: list[list[float]] = rot_2D(self.theta)
|
self.rot_moon: list[list[float]] = rot_2D(self.theta)
|
||||||
|
# Initial moon position
|
||||||
|
self.position_moon = (
|
||||||
|
self.center[0] + self.offset[0],
|
||||||
|
self.center[1] + self.offset[1],
|
||||||
|
)
|
||||||
|
|
||||||
def update_game(self) -> bool:
|
def update_game(self) -> bool:
|
||||||
# Advance the angle and recompute the rotation matrix
|
# Advance the angle and recompute the rotation matrix
|
||||||
|
|||||||
Reference in new issue
Block a user