Compute lines for the batch

This commit is contained in:
HeshamTB 2022-01-30 19:33:46 +03:00
parent be9706fef8
commit 131283890f

View File

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