diff --git a/project2/proj2.pdf b/project2/proj2.pdf new file mode 100644 index 0000000..bb83783 Binary files /dev/null and b/project2/proj2.pdf differ diff --git a/project2/sidedness.py b/project2/sidedness.py new file mode 100644 index 0000000..532d78c --- /dev/null +++ b/project2/sidedness.py @@ -0,0 +1,53 @@ +import random +from collections import namedtuple + +Point = namedtuple('Point', ['x', 'y']) + +def sidedness(p1, p2, p3): + eps = 0.00000001 + y = p1.y*(p3.x - p2.x) + x = p1.x + a = (p3.y - p2.y) + b = p3.y*(p3.x - p2.x) - a*p3.x + + if y - eps < a*x + b < y + eps: + return "ON" + elif y > a*x + b: + return "ABOVE" + else: + return "BELOW" + + + + +# test + + +p1 = Point(4,4) +p2 = Point(0,0) +p3 = Point(5,2) + + + +#print(sidedness(p1, p2, p3)) + + +def genPoint(): + a = random.uniform(1, 10) + b = random.uniform(1, 10) + + p = [] + for i in range(3): + x_i = random.uniform(1, 10) + p_i = Point(x_i, a*x_i + b) + p.append(p_i) + return p + +hej = genPoint() +print(hej) + +print(sidedness(*hej)) + + +def graham_scan(): + 3 \ No newline at end of file