Skip to content

Commit

Permalink
Fixed the equation forming problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-drew committed Jan 4, 2018
1 parent e44a593 commit 15cdeb4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions picket.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,23 @@ def check_point(self, point, debug = False):
b = 1
c = point1[1]
if debug == True:
print("Formed equation", str(a) + "y+" + str(b) + "x=" + str(c), "from points:", point1, "and", point2)
print("Formed equation", str(a) + "x+" + str(b) + "y=" + str(c), "from points:", point1, "and", point2)
line_eqns.append((a, b, c))
elif point1[0] == point2[0]:
# Vertical
a = 1
b = 0
c = point1[0]
if debug == True:
print("Formed equation", str(a) + "y+" + str(b) + "x=" + str(c), "from points:", point1, "and", point2)
print("Formed equation", str(a) + "x+" + str(b) + "y=" + str(c), "from points:", point1, "and", point2)
line_eqns.append((a, b, c))
else:
# Non vertical or hoizontal line.
a = 1
b = (-1 * ((point2[1] - point1[1]) / (point2[0] - point1[0])))
c = (point1[1] + (b * point1[0]))
a = (-1 * ((point2[1] - point1[1]) / (point2[0] - point1[0])))
b = 1
c = (point1[1] + ((-1 * ((point2[1] - point1[1]) / (point2[0] - point1[0]))) * point1[0]))
if debug == True:
print("Formed equation", str(a) + "y+" + str(b) + "x=" + str(c), "from points:", point1, "and", point2)
print("Formed equation", str(a) + "x+" + str(b) + "y=" + str(c), "from points:", point1, "and", point2)
line_eqns.append((a, b, c))
if debug == True:
print("\n")
Expand Down Expand Up @@ -144,6 +144,8 @@ def check_in_bounds(point):
else:
return(False)

if debug == True:
print("\nx bounds are:", str(self.max_x), str(self.min_x), "y bounds:", str(self.max_y), str(self.min_y))
intersection_points_left = []
intersection_points_right = []
for line in line_eqns:
Expand Down

0 comments on commit 15cdeb4

Please sign in to comment.