Skip to content

Instantly share code, notes, and snippets.

@StarOrpheus
Created October 30, 2015 09:29
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 StarOrpheus/f4e5dd05c7642dae30ec to your computer and use it in GitHub Desktop.
Save StarOrpheus/f4e5dd05c7642dae30ec to your computer and use it in GitHub Desktop.
class pt:
def __init__(self):
self.x, self.y = 0, 0
def __init__(self, tx, ty):
self.x = tx
self.y = tx
class line:
def __init__(self):
pass
def __init__(self, ax, bx, cx):
self.a = ax
self.b = bx
self.c = cx
#def __init__(self, x, y):
# self.a = y.y - x.y
# self.b = x.x - y.x
# self.c = y.x*x.y - x.x * y.y
def det(a, b):
return a.x*b.y - a.y*b.x
def lineIntersect(m, n):
z = det(pt(m.a, m.b), pt(n.a, n.b))
if(abs(z) < 1e-6):
return [False]
x = - det(pt(m.c, m.b, n.c, n.b)) / z
y = - det(pt(m.a, m.c, n.a, n.c)) / z
return [True, x, y]
@Kickoman
Copy link

Kickoman commented Nov 1, 2015

Допиши-ка ты это.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment