project_ortho mit Tests ergänzt
This commit is contained in:
1 parent
7753115638
commit
beb61664ff
2 files changed
+44
No files matched your search
+21
@@ -200,6 +200,27 @@ def rot_3D(angle: float, axis: str) -> list[list[float]]:
|
|||||||
raise ValueError(f"Unsupported rotation axis: {axis}")
|
raise ValueError(f"Unsupported rotation axis: {axis}")
|
||||||
|
|
||||||
|
|
||||||
|
def project_ortho(
|
||||||
|
point: tuple[float, float, float], scale: float = 1
|
||||||
|
) -> tuple[float, float]:
|
||||||
|
"""Project a 3‑D point orthogonally onto the xy‑plane.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
point : tuple[float, float, float]
|
||||||
|
Coordinates (x, y, z) of the point.
|
||||||
|
scale : float, optional
|
||||||
|
Scaling factor applied to the projected x and y.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
tuple[float, float]
|
||||||
|
The projected (x, y) after scaling.
|
||||||
|
"""
|
||||||
|
x, y, _ = point
|
||||||
|
return (x * scale, y * scale)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# matmul tests
|
# matmul tests
|
||||||
a1 = [[1, 2], [3, 4]]
|
a1 = [[1, 2], [3, 4]]
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
from compute import project_ortho
|
||||||
|
|
||||||
|
|
||||||
|
def test_ortho_1():
|
||||||
|
# Arrange
|
||||||
|
punkt = (1.0, 2.0, 3.0)
|
||||||
|
scale = 1
|
||||||
|
erwartet = (1.0, 2.0)
|
||||||
|
# Act
|
||||||
|
ergebnis = project_ortho(punkt, scale)
|
||||||
|
# Assert
|
||||||
|
assert ergebnis == erwartet
|
||||||
|
|
||||||
|
|
||||||
|
def test_ortho_100():
|
||||||
|
# Arrange
|
||||||
|
punkt = (1.0, 2.0, 3.0)
|
||||||
|
scale = 100
|
||||||
|
erwartet = (100.0, 200.0)
|
||||||
|
# Act
|
||||||
|
ergebnis = project_ortho(punkt, scale)
|
||||||
|
# Assert
|
||||||
|
assert ergebnis == erwartet
|
||||||
Reference in new issue
Block a user