From 80733cbedb42f159f22dcad21c34c24cc2163c17 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 25 Jan 2022 22:26:15 +0300 Subject: [PATCH] basictypes: working well with lines Signed-off-by: HeshamTB --- basictypes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/basictypes.py b/basictypes.py index 4d3055c..ae36187 100644 --- a/basictypes.py +++ b/basictypes.py @@ -74,11 +74,15 @@ class Line: class WallIDMismatch (RuntimeError): ... # Helper methods -def polar_to_cart(self, r, theta_deg) -> tuple: +def polar_to_cart(r, theta_deg) -> tuple: #print('polar to cart ',r, theta_deg) x = r * math.cos(deg_to_rad(theta_deg)) y = r * math.sin(deg_to_rad(theta_deg)) return x,y def deg_to_rad(theta_deg) -> float: - return theta_deg*(math.pi/180) \ No newline at end of file + return theta_deg*(math.pi/180) + +def point_from_polar(r, theta, wall_id) -> PointWithID: + x, y = polar_to_cart(r, theta) + return PointWithID(x, y, wall_id)