Commit 9ba1c61d authored by DYPonomarev's avatar DYPonomarev
Browse files

Update Объекты.py

parents
import math as m
dt = 0.001
class TAObject:
def __init__(self, x, y):
self.f = True
self.x = x
self.y = y
def __del__(self):
print('Destructor called. Object deleted!')
class TLA(TAObject):
def __init__(self, x, y, xc, yc, v):
super().__init__(x, y)
self.xc = xc
self.yc = yc
self.r = m.sqrt((self.x - self.xc)**2+(self.y - self.yc)**2)
self.v = v
if self.x > self.xc:
self.b = 0
elif self.y < self.yc:
self.b = -1
elif self.x < self.xc and self.y > self.yc:
self.b = 1
self.fi = self.b*m.pi + m.atan((self.y - self.yc) / (self.x - self.xc))
self.landing = False
def move(self, a):
if a == 0:
self.f = False
elif a == 1:
self.f = True
class TAircraft(TLA):
def __init__(self, x, y, xc, yc, v):
super().__init__(x, y, xc, yc, v)
self.types = 'AC'
def move(self, t, a):
self.omega = -self.v/self.r
self.x = -(self.xc + self.r *m.cos(self.fi + self.omega*t))*(a-1)+a*(self.x + self.v * dt)
self.y = -(self.yc + self.r * m.sin(self.fi + self.omega*t))*(a-1)+self.y * a
class THelicopter(TLA):
def __init__(self, x, y, xc, yc, v):
super().__init__(x, y, xc, yc, v)
self.types = 'HC'
def move(self, a):
self.x = self.x - a*self.v*m.cos(self.fi)*dt
self.y = self.y - a*self.v*m.sin(self.fi)*dt
class TAirport(TAObject):
def __init__(self, x, y, l, LA):
super().__init__(x, y)
self.l = l
self.LA = LA
def Do(self, t0, tk):
while t0 < tk:
for aircraft in self.LA:
X = self.x + 1.1 * self.l
if aircraft.types == 'AC':
if aircraft.x > self.x + self.l and aircraft.f == True:
aircraft.landing = True
elif self.f == True:
aircraft.landing = False
if not(self.f and not aircraft.f) and aircraft.x < X and abs(aircraft.y - self.y) < self.l / 50:
self.a = 1
else:
self.a = 0
else:
if (aircraft.x - self.x)**2 + (aircraft.y - self.y)**2 < (self.l / 50)** 2 and aircraft.f == True:
aircraft.landing = True
else:
aircraft.landing = False
if not(self.f and not aircraft.f):
self.a = 1
else:
self.a = 0
aircraft.move(t0, self.a)
t0 += dt
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment