From 57f7e9140eaf216ede19533ff34ab154e642de4a Mon Sep 17 00:00:00 2001 From: Xeon0X Date: Tue, 11 Jun 2024 19:36:04 +0200 Subject: [PATCH] Add tests --- main.py | 2 +- networks/geometry/Segment2D.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 029ec59..1eefd64 100644 --- a/main.py +++ b/main.py @@ -268,5 +268,5 @@ block_list = ["blue_concrete", "red_concrete", "green_concrete", print(Polyline((Point2D(0, 0), Point2D(0, 10), Point2D(50, 10), Point2D(20, 20)))) -s = Segment3D(Point3D(0, 0, 0), Point3D(10, 10, 10)).perpendicular(10) +s = Segment2D(Point2D(0, 0), Point2D(10, 10)).perpendicular(10) print(s) diff --git a/networks/geometry/Segment2D.py b/networks/geometry/Segment2D.py index 3801777..fd35b7c 100644 --- a/networks/geometry/Segment2D.py +++ b/networks/geometry/Segment2D.py @@ -200,6 +200,9 @@ class Segment2D: Returns: List[Point2D]: Two points. First one positioned on the counterclockwise side of the segment, oriented from start to end (meaning left). + + >>> Segment2D(Point2D(0, 0), Point2D(10, 10)).perpendicular(10) + (Point2D(x: -4, y: 4), Point2D(x: 4, y: -4)) """ delta = self.start.distance(self.end) dx = (self.start.x - self.end.x) / delta