From 131283890f7beec73941e02dd5111d703d2e1a4a Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 30 Jan 2022 19:33:46 +0300 Subject: [PATCH] Compute lines for the batch --- mklines.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mklines.py b/mklines.py index 29d7c75..e76a7ea 100644 --- a/mklines.py +++ b/mklines.py @@ -6,7 +6,7 @@ import csv import sys import math from os.path import exists as file_exists -from basictypes import PointWithID, Line, point_from_polar +from basictypes import PointWithID, StraightLine, point_from_polar def main(): @@ -19,7 +19,17 @@ def main(): if not valid_data(points): # Assumes header is removed perr('Invalid or corrupt samples') return -1 - for val in points: print(val.get_cartesian()) + #for val in points: print(val.get_cartesian()) + lines = set() + 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) + print('line ', line.get_m(), line.get_b()) + #for line in lines: print(line.get_m()) return 0 def read_csv(filename: str, remove_header=False) -> list[PointWithID]: @@ -35,7 +45,7 @@ def read_csv(filename: str, remove_header=False) -> list[PointWithID]: return tmp_data def valid_data(samples:list) -> bool: - # Check if we have even number of samples + # Check if we have an even number of samples return len(samples) % 2 == 0