From 0fe311e9598121b459a29f7f61a84c0ef1d14190 Mon Sep 17 00:00:00 2001 From: Obayne Date: Tue, 23 Sep 2025 02:23:58 -0500 Subject: [PATCH 1/2] feat(cad_core): Add is_parallel function --- cad_core/lines.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cad_core/lines.py b/cad_core/lines.py index 112eb70..8e7ebb8 100644 --- a/cad_core/lines.py +++ b/cad_core/lines.py @@ -152,6 +152,7 @@ def trim_segment_by_cutter(seg: Line, cutter: Line, end: str = "b", tol: float = __all__ = [ "Point", "Line", + "is_parallel", "intersection_line_line", "extend_line_end_to_point", "extend_line_to_intersection", From 6cf554d29589fe750774c5f260a1e2207d49c1b9 Mon Sep 17 00:00:00 2001 From: Obayne Date: Tue, 23 Sep 2025 02:27:20 -0500 Subject: [PATCH 2/2] test(cad_core): Add tests for is_parallel function Adds tests for the is_parallel function to cover the following scenarios: --- tests/cad_core/test_is_parallel.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/cad_core/test_is_parallel.py diff --git a/tests/cad_core/test_is_parallel.py b/tests/cad_core/test_is_parallel.py new file mode 100644 index 0000000..277ab29 --- /dev/null +++ b/tests/cad_core/test_is_parallel.py @@ -0,0 +1,21 @@ +from cad_core.lines import Line, Point, is_parallel + +def test_parallel_lines(): + l1 = Line(Point(0, 0), Point(10, 0)) + l2 = Line(Point(0, 10), Point(10, 10)) + assert is_parallel(l1, l2) is True + +def test_non_parallel_lines(): + l1 = Line(Point(0, 0), Point(10, 0)) + l2 = Line(Point(0, 0), Point(0, 10)) + assert is_parallel(l1, l2) is False + +def test_collinear_lines(): + l1 = Line(Point(0, 0), Point(10, 0)) + l2 = Line(Point(20, 0), Point(30, 0)) + assert is_parallel(l1, l2) is True + +def test_nearly_parallel_lines(): + l1 = Line(Point(0, 0), Point(1000, 0)) + l2 = Line(Point(0, 1e-10), Point(1000, 1e-10)) + assert is_parallel(l1, l2) is True