Add orthogonal projection and tests

This commit is contained in:
Amalia Sucipto committed 2026-10-28 23:00:08 +01:00
1 parent 17eff74d0c
commit 4931d5e7dc
4 files changed
+46 -2

No files matched your search

+18 -1
View File
@@ -135,7 +135,7 @@ def rot_2D(theta: float) -> Matrix:
[sin(theta), cos(theta)],
]
def rot_3D(angle: float, axis: str) -> list[list[float]]:
def rot_3D(angle: float, axis: str) -> Matrix:
"""Create a 3D rotation matrix around the specified axis.
Args:
@@ -175,6 +175,23 @@ def rot_3D(angle: float, axis: str) -> list[list[float]]:
else:
raise ValueError("Axis must be 'x', 'y', or 'z'.")
def project_ortho(
point: tuple[float, float, float],
scale: float = 1,
) -> tuple[float, float]:
"""Project a 3D point orthogonally onto the xy-plane.
Args:
point: A 3D point containing x, y, and z coordinates.
scale: Scaling factor for the projected coordinates.
Returns:
The scaled 2D coordinates of the projected point.
"""
x, y, z = point
return (x * scale, y * scale)
if __name__ == "__main__":
# Beispiel Multiplikation