-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.Point.py
More file actions
56 lines (52 loc) · 1.82 KB
/
2.Point.py
File metadata and controls
56 lines (52 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import math
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
#def __copy__(self):
def distance(self,other):
return ((self.x - other.x) ** 2 + (self.y - other.y) ** 2) ** 0.5
class Triangle:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def perimeter(self):
return a.distance(b) + a.distance(c) + b.distance(c)
def area(self):
p = (a.distance(b) + a.distance(c) + b.distance(c)) / 2
return (p * (p - a.distance(b)) * (p - a.distance(c)) * (p - b.distance(c))) ** 0.5
def contains(self):
p = (a.distance(b) + a.distance(c) + b.distance(c)) / 2
p1 = (z.distance(a) + z.distance(b) + a.distance(b)) / 2
p2 = (z.distance(a) + z.distance(c) + a.distance(c)) / 2
p3 = (z.distance(b) + z.distance(c) + b.distance(c)) / 2
if (p * (p - a.distance(b)) * (p - a.distance(c)) * (p - b.distance(c))) ** 0.5 <= \
((p1 * (p1 - z.distance(a)) * (p1 - z.distance(b)) * (p1 - a.distance(b))) ** 0.5 + \
(p2 * (p2 - z.distance(a)) * (p2 - z.distance(c)) * (p2 - a.distance(c))) ** 0.5 + \
(p3 * (p3 - z.distance(b)) * (p3 - z.distance(c)) * (p3 - b.distance(c))) ** 0.5):
return "In"
else:
return "Out"
class Circle:
def __init__(self,d,r):
self.d = d
self.r = r
def length(self):
return 2 * math.pi * self.r
def area_circle(self):
return math.pi * self.r ** 2
def in_or_out(self):
if (d.x - z.x) ** 2 + (d.y - z.y) ** 2 <= self.r ** 2:
return "In"
else:
return "Out"
a = Point(0,0)
b = Point(3,0)
c = Point(0,4)
d = Point(4,4)
z = Point(1,1)
tri = Triangle(a,b,c)
cir = Circle(d,int(input()))
#print(tri.contains())
print(cir.in_or_out())