Created
October 30, 2015 09:29
-
-
Save StarOrpheus/f4e5dd05c7642dae30ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Допиши-ка ты это.