basictypes: working well with lines

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2022-01-25 22:26:15 +03:00
parent 5d73bca7ba
commit 80733cbedb
Signed by: Hesham
GPG Key ID: 74876157D199B09E

View File

@ -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)
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)