cleanup
Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
		
							parent
							
								
									80733cbedb
								
							
						
					
					
						commit
						d0a2cbb0db
					
				@ -56,10 +56,9 @@ class Line:
 | 
			
		||||
        self.m, self.b = self.__find_line(p1, p2)
 | 
			
		||||
        v = ValueError()
 | 
			
		||||
        if not self.__matching_wall_ids(p1, p2): 
 | 
			
		||||
            raise WallIDMismatch('Wall ID for points do not match')
 | 
			
		||||
            raise WallIDMismatch('Wall ID for points does not match')
 | 
			
		||||
 | 
			
		||||
    def __find_line(self, p1:PointWithID, p2:PointWithID) -> float:
 | 
			
		||||
        # m = ((point2[1] - point1[1])/(point2[0] - point1[0]))
 | 
			
		||||
        m = (p2.get_y() - p1.get_y()) / (p2.get_x() - p1.get_x())
 | 
			
		||||
        # Using p1 to find b
 | 
			
		||||
        b = p1.get_y() - (m*p1.get_x())
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								mklines.py
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								mklines.py
									
									
									
									
									
								
							@ -6,6 +6,7 @@ import csv
 | 
			
		||||
import sys
 | 
			
		||||
import math
 | 
			
		||||
from os.path import exists as file_exists
 | 
			
		||||
from basictypes import PointWithID, Line
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
@ -29,18 +30,11 @@ def read_csv(filename: str, remove_header=False) -> list:
 | 
			
		||||
            new_row = list()
 | 
			
		||||
            if remove_header and i == 0: continue
 | 
			
		||||
            for i, val in enumerate(row):
 | 
			
		||||
                if i == 0: new_row.append(val)
 | 
			
		||||
                if i == 0: new_row.append(val) # Append wall_id as is
 | 
			
		||||
                else: new_row.append(float(val))
 | 
			
		||||
            tmp_data.append(new_row)
 | 
			
		||||
    return tmp_data
 | 
			
		||||
 | 
			
		||||
def get_line_eq(point1, point2)-> tuple:
 | 
			
		||||
    m = ((point2[1] - point1[1])/(point2[0] - point1[0]))
 | 
			
		||||
    # y = mx + b
 | 
			
		||||
    # b = y - mx
 | 
			
		||||
    # Using p1 to find b
 | 
			
		||||
    b = point1[1] - (m*point1[0])
 | 
			
		||||
 | 
			
		||||
def valid_data(samples:list) -> bool:
 | 
			
		||||
    # Check if we have even number of samples
 | 
			
		||||
    return len(samples) % 2 == 0
 | 
			
		||||
@ -57,9 +51,6 @@ def polarlist_to_cart(polar_points: list):
 | 
			
		||||
        p2 = polar_to_cart(p2[0],p2[1])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def points_to_straight_line():
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
def get_filename() -> str:
 | 
			
		||||
    try:
 | 
			
		||||
        filename = sys.argv[1]
 | 
			
		||||
@ -68,8 +59,8 @@ def get_filename() -> str:
 | 
			
		||||
        perr('Provide target file name')
 | 
			
		||||
        return -1
 | 
			
		||||
 | 
			
		||||
def perr(msg):
 | 
			
		||||
    print(msg, file=sys.stderr)
 | 
			
		||||
def perr(*args):
 | 
			
		||||
    print(args, file=sys.stderr)
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    exit(main())
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user