Skip to content

Commit

Permalink
adding another test
Browse files Browse the repository at this point in the history
  • Loading branch information
romanarust committed May 9, 2024
1 parent ec8996a commit 9b2f245
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_straight_skeleton_2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from compas_cgal.straight_skeleton_2 import create_interior_straight_skeleton
from compas.tolerance import TOL


def test_straight_polygon():
Expand All @@ -14,3 +15,43 @@ def test_straight_polygon():
]
lines = create_interior_straight_skeleton(points)
assert len(lines) == 8


def test_straight_polygon_2_compare():
points = [
(-1.91, 3.59, 0.0),
(-5.53, -5.22, 0.0),
(-0.39, -1.98, 0.0),
(2.98, -5.51, 0.0),
(4.83, -2.02, 0.0),
(9.70, -3.63, 0.0),
(12.23, 1.25, 0.0),
(3.42, 0.66, 0.0),
(2.92, 4.03, 0.0),
(-1.91, 3.59, 0.0),
]
lines = create_interior_straight_skeleton(points)

expected = [
[[-1.91, 3.59, 0.0], [-0.139446292, 1.191439787, 0.0]],
[[-5.53, -5.22, 0.0], [-0.139446292, 1.191439787, 0.0]],
[[-0.39, -1.98, 0.0], [0.008499564, 1.241560466, 0.0]],
[[2.98, -5.51, 0.0], [2.44972507, -1.674799065, 0.0]],
[[4.83, -2.02, 0.0], [4.228131167, -0.522007766, 0.0]],
[[8.663865218, -1.084821998, 0.0], [9.7, -3.63, 0.0]],
[[12.23, 1.25, 0.0], [8.663865218, -1.084821998, 0.0]],
[[3.42, 0.66, 0.0], [1.755862468, -1.404991433, 0.0]],
[[2.92, 4.03, 0.0], [0.563706846, 1.033296141, 0.0]],
[[4.228131167, -0.522007766, 0.0], [2.44972507, -1.674799065, 0.0]],
[[4.228131167, -0.522007766, 0.0], [8.663865218, -1.084821998, 0.0]],
[[1.755862468, -1.404991433, 0.0], [2.44972507, -1.674799065, 0.0]],
[[0.563706846, 1.033296141, 0.0], [1.755862468, -1.404991433, 0.0]],
[[-0.139446292, 1.191439787, 0.0], [0.008499564, 1.241560466, 0.0]],
[[0.563706846, 1.033296141, 0.0], [0.008499564, 1.241560466, 0.0]],
]
for act, exp in zip(lines, expected):
sa, ea = act
se, ee = exp
# the line direction sometimes changes ...
assert TOL.is_allclose(sa, se) or TOL.is_allclose(sa, ee)
assert TOL.is_allclose(ea, ee) or TOL.is_allclose(ea, se)

0 comments on commit 9b2f245

Please sign in to comment.