Advertisement
Guest User

aaaaaaaaaaafghy

a guest
Feb 7th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. def cross_point(x11, y11, x12, y12, x21, y21, x22, y22): # находим точку
  2. if x12 != x11 and y11 != y12 and x22 != x21 and y21 != y22:
  3. a1 = 1 / (x12 - x11)
  4. b1 = 1 / (y11 - y12)
  5. a2 = 1 / (x22 - x21)
  6. b2 = 1 / (y21 - y22)
  7. c1 = x11 / (x12 - x11) - y11 / (y12 - y11)
  8. c2 = x21 / (x22 - x21) - y21 / (y22 - y21)
  9. delta = a1 * b2 - a2 * b1
  10. delta_x = c1 * b2 - c2 * b1
  11. delta_y = a1 * c2 - a2 * c1
  12. x = delta_x / delta
  13. y = delta_y / delta
  14. else:
  15. if x12 == x11:
  16. x=x12
  17. if y12 == y11:
  18. y=y12
  19. if x22 == x21:
  20. x=x12
  21. if y21 == y22:
  22. y=y12
  23. return [x,y]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement