forked from deoel/43
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coord_xy_xy.py
52 lines (42 loc) · 1.31 KB
/
coord_xy_xy.py
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
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
return "(%s, %s) " % (self.x, self.y)
class Coord_XY_XY:
def __init__(self, x0,y0,x1,y1):
self.x0 = x0
self.x1 = x1
self.y0 = y0
self.y1 = y1
self.creer_point()
def __str__(self):
return self.A.__str__() + self.B.__str__() + self.C.__str__() + self.D.__str__()
def creer_point(self):
A = Point(self.x0, self.y0)
B = Point(self.x1, self.y0)
C = Point(self.x0, self.y1)
D = Point(self.x1, self.y1)
self.A = A
self.B = B
self.C = C
self.D = D
def collision(self, CXY):
if self.A.y > CXY.C.y:
return False
elif self.B.x < CXY.A.x:
return False
elif self.D.y < CXY.B.y:
return False
elif self.C.x > CXY.D.x:
return False
else:
return True
def in_limite(self, CXY):
if self.A.x <= CXY.A.x and CXY.A.x <= self.B.x:
if self.A.x <= CXY.B.x and CXY.B.x <= self.B.x:
if self.A.y <= CXY.A.y and CXY.A.y <= self.C.y:
if self.A.y <= CXY.C.y and CXY.C.y <= self.C.y:
return True
return False