From bc790e21c300b5915d9f1ae2cb88b8709784c4d2 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 14 Feb 2022 14:46:47 +0300 Subject: [PATCH] mklines: fixes and batch calculation Signed-off-by: HeshamTB --- mklines.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mklines.py b/mklines.py index e76a7ea..85c049b 100644 --- a/mklines.py +++ b/mklines.py @@ -20,16 +20,20 @@ def main(): perr('Invalid or corrupt samples') return -1 #for val in points: print(val.get_cartesian()) - lines = set() + lines = list() for i in range(0, len(points), 2): p1 = points[i] p2 = points[i+1] print('p1 ', p1.get_x(), p1.get_y()) print('p2 ', p2.get_x(), p2.get_y()) line = StraightLine(p1, p2) - lines.add(line) + lines.append(line) print('line ', line.get_m(), line.get_b()) - #for line in lines: print(line.get_m()) + intercepts = list() + for i, line in enumerate(lines): + if i == len(lines) - 1: break # Last line is a special case + p = lines[i].intercept(lines[i+1]) + print(p.get_x(), p.get_y()) return 0 def read_csv(filename: str, remove_header=False) -> list[PointWithID]: