project_ortho + tests laufen
This commit is contained in:
1 parent
ae46e0646c
commit
ff9289c767
4 files changed
+42
-2
No files matched your search
@@ -1 +1,2 @@
|
|||||||
from .compute import matmul, transpose, rot_2D, rot_3D
|
from .compute import matmul, transpose, rot_2D, rot_3D
|
||||||
|
from .projection import project_ortho
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
def project_ortho(point: tuple[float, float, float], scale: float = 1) -> tuple[float, float]:
|
||||||
|
""" projected 3D-Point orthogonal auf 2D (xy), z Koordinate wird ignoriert
|
||||||
|
|
||||||
|
point : tuple[float, float, float]
|
||||||
|
3-D point (x, y, z).
|
||||||
|
scale : float, optional
|
||||||
|
Scaling factor applied (default 1)
|
||||||
|
"""
|
||||||
|
x, y, _ = point
|
||||||
|
return (x * scale, y * scale)
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from matrixmania import project_ortho
|
||||||
|
|
||||||
|
def test_project_ortho_ohne_skalierung():
|
||||||
|
# Arrange
|
||||||
|
punkt = (1.0, 2.0, 3.0)
|
||||||
|
erwartet = (1.0, 2.0)
|
||||||
|
|
||||||
|
# Act
|
||||||
|
ergebnis = project_ortho(punkt)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert ergebnis == pytest.approx(erwartet)
|
||||||
|
|
||||||
|
|
||||||
|
def test_project_ortho_mit_skalierung_100():
|
||||||
|
# Arrange
|
||||||
|
punkt = (1.0, 2.0, 3.0)
|
||||||
|
scale = 100
|
||||||
|
erwartet = (100.0, 200.0)
|
||||||
|
|
||||||
|
# Act
|
||||||
|
ergebnis = project_ortho(punkt, scale=scale)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert ergebnis == pytest.approx(erwartet) #würde hier auch ohne approx gehen
|
||||||
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import math
|
import math, pytest
|
||||||
import pytest
|
|
||||||
|
|
||||||
from matrixmania import rot_2D, rot_3D
|
from matrixmania import rot_2D, rot_3D
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user