18 lines
702 B
Python
18 lines
702 B
Python
|
|
|
|
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)
|
|
|
|
def project_perspective(point: tuple[float, float, float], focal_length: float = 1.0, scale: float = 1.0, camera_distance: float = 4.0) -> tuple[float, float]:
|
|
x, y, z = point
|
|
x_2d = x * focal_length / (z + camera_distance) * scale
|
|
y_2d = y * focal_length / (z + camera_distance) * scale
|
|
return (x_2d, y_2d) |