- Implement tests for image layer functionality including alpha curve and depth layer behavior. - Create tests for image plane evaluation and modifier input handling. - Add tests to verify the saved asset inventory and its persistence. - Introduce tests for the documentation command to ensure correct project version deployment. - Validate the extension manifest structure and required permissions. - Develop tests for the packaging process, ensuring correct platform handling and dependency management. - Enhance image depth plane group functionality with new split threshold input and surface processing.
37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
import numpy as np
|
|
import pytest
|
|
|
|
|
|
from anyimage.common.selection import clip_polygon_halfplanes
|
|
from anyimage.operators import frame_tool as frame
|
|
|
|
|
|
@pytest.mark.parametrize("focal", [1, 1.7, 2, 4])
|
|
@pytest.mark.parametrize("angle,depth", [(30, 0.2), (0, 1e-14)])
|
|
def test_frame_overlap_matches_finite_front_samples(focal, angle, depth):
|
|
projection = np.eye(4)
|
|
projection[0, 0] = projection[1, 1] = focal
|
|
projection[3] = (0, 0, -1, 0)
|
|
c, s = np.cos(np.radians(angle)), np.sin(np.radians(angle))
|
|
world = np.eye(4)
|
|
world[:3, :3] = ((c, 0, s), (0, 1, 0), (-s, 0, c))
|
|
world[2, 3] = -depth
|
|
source = frame.frame_source_projection(
|
|
projection, np.eye(4), world, (-1, 1, -1, 1), (100, 100), perspective=True
|
|
)
|
|
source["image_size"] = (100, 100)
|
|
assert frame.frame_source_coordinates(source, np.array(((50, 50),)))[2][0]
|
|
overlap = frame.frame_source_overlap(source, ((0, 100), (100, 100), (100, 0), (0, 0)))
|
|
assert len(overlap) >= 3
|
|
assert np.isfinite(overlap).all()
|
|
|
|
|
|
@pytest.mark.parametrize("scale", [1e-14, 1, 1e14])
|
|
def test_halfplane_clipping_is_scale_invariant(scale):
|
|
square = ((0, 0), (2, 0), (2, 2), (0, 2))
|
|
result = clip_polygon_halfplanes(square, ((-scale, 0, scale),))
|
|
assert set(result) == {(0, 0), (1, 0), (1, 2), (0, 2)}
|
|
assert clip_polygon_halfplanes(square, ((1, 0, -3),)) == ()
|
|
edge = clip_polygon_halfplanes(square, ((1, 0, -2),))
|
|
assert all(x == 2 for x, y in edge)
|