Skip to content

Commit

Permalink
Merge pull request #12 from Cambridge-ICCS/impl2
Browse files Browse the repository at this point in the history
Implement `equation_of_line` using determinant approach
  • Loading branch information
TomMelt authored Jul 10, 2024
2 parents b8eda28 + bd8f6e3 commit 059a087
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,7 @@ def equation_of_line(a, b):
x0, y0 = a
x1, y1 = b

if (x0 == x1):
# Special case of a vertical line

def f(x, y):
return x - x0

else:

def f(x, y):
m = (y1 - y0) / (x1 - x0)
c = y0 - m * x0
return y - m * x - c
def f(x, y):
return (x1 - x0) * (y - y0) - (y1 - y0) * (x - x0)

return f

0 comments on commit 059a087

Please sign in to comment.