Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt
- class cDot:
- x = y = 0
- def __init__(self, _x, _y):
- self.x = _x
- self.y = _y
- def __str__(self):
- return 'cDot(' + str(self.x) + ', ' + str(self.y) + ')'
- class cVec:
- x = y = 0
- def __init__(self, _x, _y):
- self.x = _x
- self.y = _y
- def __str__(self):
- return 'cVec(' + str(self.x) + ', ' + str(self.y) + ')'
- def fillDots():
- dots = []
- for i in range(3):
- x, y = map(int, input().split())
- dots.append(cDot(x, y))
- minxDt = 0;
- for i in range(1, 3):
- if(dots[minxDt].x > dots[i].x):
- minxDt = i
- dots[0], dots[minxDt] = dots[minxDt], dots[0]
- maxxDt = 0;
- for i in range(1, 3):
- if(dots[maxxDt].x < dots[i].x):
- maxxDt = i
- dots[2], dots[maxxDt] = dots[maxxDt], dots[2]
- return dots
- def fillVects(dots):
- vects = []
- vects.append(cVec(dots[1].x - dots[0].x, dots[1].y - dots[0].y))
- vects.append(cVec(dots[2].x - dots[1].x, dots[2].y - dots[1].y))
- vects.append(cVec(dots[0].x - dots[2].x, dots[0].y - dots[2].y))
- return vects
- def fillPVects(dots, p):
- pvects = []
- pvects.append(cVec(p.x - dots[0].x, p.y - dots[0].y))
- pvects.append(cVec(p.x - dots[1].x, p.y - dots[1].y))
- pvects.append(cVec(p.x - dots[2].x, p.y - dots[2].y))
- return pvects
- def mult(a, b):
- return (a.x * b.y) - (b.x * a.y)
- #******************************************** main
- dots = []
- vects = []
- pvects = []
- dots = fillDots()
- x, y = map(int, input().split())
- p = cDot(x, y)
- vects = fillVects(dots)
- pvects = fillPVects(dots, p)
- sign = []
- for i in range(3):
- if mult(pvects[i], vects[i]) >= 0:
- sign.append(1)
- else:
- sign.append(0)
- if (sign[0] == sign[1]) and (sign[1] == sign[2]):
- print('In')
- else:
- print('Out')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement