Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def cross_point(x11, y11, x12, y12, x21, y21, x22, y22): # находим точку
- if x12 != x11 and y11 != y12 and x22 != x21 and y21 != y22:
- a1 = 1 / (x12 - x11)
- b1 = 1 / (y11 - y12)
- a2 = 1 / (x22 - x21)
- b2 = 1 / (y21 - y22)
- c1 = x11 / (x12 - x11) - y11 / (y12 - y11)
- c2 = x21 / (x22 - x21) - y21 / (y22 - y21)
- delta = a1 * b2 - a2 * b1
- delta_x = c1 * b2 - c2 * b1
- delta_y = a1 * c2 - a2 * c1
- x = delta_x / delta
- y = delta_y / delta
- else:
- if x12 == x11:
- x=x12
- if y12 == y11:
- y=y12
- if x22 == x21:
- x=x12
- if y21 == y22:
- y=y12
- return [x,y]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement