new: project_ortho

This commit is contained in:
Rebecca committed 2026-10-22 16:53:12 +02:00
1 parent 0aa2468d19
commit c5d47760ec
2 files changed
+20 -2

No files matched your search

+2 -2
View File
@@ -1,3 +1,3 @@
from .compute import matmul, rot_2D, rot_3D, transpose
from .compute import matmul, project_ortho, rot_2D, rot_3D, transpose
__all__ = ["matmul", "rot_2D", "rot_3D", "transpose"]
__all__ = ["matmul", "project_ortho", "rot_2D", "rot_3D", "transpose"]
+18
View File
@@ -95,6 +95,24 @@ def rot_3D(angle: float, axis: str) -> list[list[float]]:
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 onto the xy-plane and apply a scale factor.
The z-coordinate is ignored. The returned x- and y-coordinates are each
multiplied by ``scale``.
Args:
point: The 3D point as an (x, y, z) tuple.
scale: The scale factor to apply to x and y.
Returns:
The scaled 2D point as an (x, y) tuple.
"""
return point[0] * scale, point[1] * scale
def _validate_matrix(matrix: list[list[float]], name: str) -> None:
"""Raise ValueError unless matrix is non-empty and rectangular."""
if not matrix: