Merge pull request #1062 from Mx-El/Perspective-Render
Some checks failed
benchmarks / benchmarks (macos-13, 3.12) (push) Has been cancelled
benchmarks / benchmarks (macos-14, 3.12) (push) Has been cancelled
benchmarks / benchmarks (ubuntu-latest, 3.12) (push) Has been cancelled
benchmarks / benchmarks (windows-latest, 3.12) (push) Has been cancelled
Upload coverage reports to Codecov / run (push) Has been cancelled
pylint / lint (3.10) (push) Has been cancelled
Run type checker / typecheck (3.10) (push) Has been cancelled
Run type checker / typecheck (3.13) (push) Has been cancelled
Wheel building and publishing / Build wheel on ubuntu-latest (push) Has been cancelled
tests / tests (macos-13, 3.10) (push) Has been cancelled
tests / tests (macos-13, 3.13) (push) Has been cancelled
tests / tests (macos-14, 3.10) (push) Has been cancelled
tests / tests (macos-14, 3.13) (push) Has been cancelled
tests / tests (ubuntu-latest, 3.10) (push) Has been cancelled
tests / tests (ubuntu-latest, 3.13) (push) Has been cancelled
tests / tests (windows-latest, 3.10) (push) Has been cancelled
tests / tests (windows-latest, 3.13) (push) Has been cancelled
Wheel building and publishing / upload_pypi (push) Has been cancelled

add ability to do perspective projection
This commit is contained in:
Roger Maitland 2025-08-06 09:34:42 -04:00 committed by GitHub
commit 7c19910382
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -920,6 +920,7 @@ class Mixin1D(Shape):
viewport_origin: VectorLike,
viewport_up: VectorLike = (0, 0, 1),
look_at: VectorLike | None = None,
focus: float | None = None,
) -> tuple[ShapeList[Edge], ShapeList[Edge]]:
"""project_to_viewport
@ -931,6 +932,8 @@ class Mixin1D(Shape):
Defaults to (0, 0, 1).
look_at (VectorLike, optional): point to look at.
Defaults to None (center of shape).
focus (float, optional): the focal length for perspective projection
Defaults to None (orthographic projection)
Returns:
tuple[ShapeList[Edge],ShapeList[Edge]]: visible & hidden Edges
@ -963,7 +966,11 @@ class Mixin1D(Shape):
gp_Ax1(viewport_origin.to_pnt(), projection_dir.to_dir())
)
camera_coordinate_system.SetYDirection(viewport_up.to_dir())
projector = HLRAlgo_Projector(camera_coordinate_system)
projector = (
HLRAlgo_Projector(camera_coordinate_system, focus)
if focus
else HLRAlgo_Projector(camera_coordinate_system)
)
hidden_line_removal.Projector(projector)
hidden_line_removal.Update()