Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt
- def is_inside(x, y, x1, y1, x2, y2, x3, y3):
- s = get_square(x1, y1, x2, y2, x3, y3)
- s1 = get_square(x, y, x2, y2, x3, y3)
- s2 = get_square(x1, y1, x, y, x3, y3)
- s3 = get_square(x1, y1, x2, y2, x, y)
- s_new = s1 + s2 + s3
- pogr = 0.01
- return abs(s_new - s) < pogr
- def get_square(x1, y1, x2, y2, x3, y3):
- a = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
- b = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3))
- c = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3))
- p = (a + b + c) / 2
- try:
- s = sqrt(p * (p - a) * (p - b) * (p - c))
- except ValueError:
- print(p - a, p - b, p - c)
- return False
- return s
- tr = '''4 10 10 4 1 1
- -7 10 0 3 -10 0
- 17 23 -1 2 -1 23
- -77 -10 -5 -20 -80 -23
- 4 1 5 9 5 1
- -12 20 -10 8 -10 20
- 60 60 90 93 90 60
- 3 0 20 23 0 20
- -7 -30 10 -47 10 -30
- -10 40 25 -7 -13 -10'''.split('\n')
- x1, y1, x2, y2, x3, y3 = map(int, tr[0].split())
- for x in range(-100, 101):
- for y in range(-100, 101):
- if is_inside(x, y, x1, y1, x2, y2, x3, y3):
- pass
- #print(x, y)
- #print(tr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement