Skip to content

Instantly share code, notes, and snippets.

@MiyamotoAkira
Created July 5, 2017 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MiyamotoAkira/a3761c73bdd692bb9047e078770613e8 to your computer and use it in GitHub Desktop.
Save MiyamotoAkira/a3761c73bdd692bb9047e078770613e8 to your computer and use it in GitHub Desktop.
class Line:
def __init__(self, x1, y1, x2, y2):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
def find_x(self, y):
return ((self.x2*(y-self.y1)) - (self.x1*y)+(self.x1*self.y2))/(self.y2-self.y1)
def find_y(self, x):
return ((self.y2*(x-self.y1)) - (self.y1*x)+(self.y1*self.x2))/(self.x2-self.x1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment