Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1.     def intersects(self, line2):
  2.         # oversimplification?
  3.         if self.dir == line2.dir:
  4.             return []
  5.         if self.dir == "X":
  6.             assert line2.p1.x == line2.p2.x
  7.             if self.p1.x < line2.p1.x and self.p2.x > line2.p1.x:
  8.                 if line2.p1.y < self.p1.y and line2.p2.y > self.p1.y:
  9.                     return [Pt(line2.p1.x, self.p1.y)]
  10.                 else:
  11.                     return []
  12.             else:
  13.                 return []
  14.         elif self.dir == "Y":
  15.             assert line2.dir == "X"
  16.             return line2.intersects(self)
  17.         else:
  18.             raise RuntimeError("Hm, F.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement