Commit fb401dfc authored by KTKadyshev's avatar KTKadyshev
Browse files

Upload New File

parent 260ac66e
dt = 1.0
import math
from abc import ABC, abstractmethod
class TTarget(ABC):
def __init__(self, x0, y0, k, v):
self.x0 = x0
self.y0 = y0
self.k = k
self.v = v
self.t0 = 0
self.x = x0
self.y = y0
@abstractmethod
def move(self, ti):
pass
class TAircraft(TTarget):
def __init__(self, x0, y0, k, v):
super().__init__(x0, y0, k, v)
def move(self, ti):
self.x = self.x0 - self.v * math.cos(self.k) * ti
self.y = self.y0 - self.v * math.sin(self.k) * ti
class TMissile(TTarget):
def __init__(self, x0, y0, k, v, n):
super().__init__(x0, y0, k, v)
self.n = n
def move(self, ti):
self.x = self.x0 - (self.v + self.n * ti) * math.cos(self.k) * ti
self.y = self.y0 - (self.v + self.n * ti) * math.sin(self.k) * ti
class Information:
def __init__(self, xc, yc, r0, ttarget):
self.xc = xc
self.yc = yc
self.r0 = r0
self.ttarget = ttarget
self.text = open('file.txt', 'a')
def peleng(self, t0, tk):
while t0 < tk:
for ttarget in self.ttarget:
ttarget.move(t0)
d = ((ttarget.x - self.xc) ** 2 + (ttarget.y - self.yc)) ** 0.5
if d <= self.r0:
az = math.atan((ttarget.y - self.yc) / (ttarget.x - self.xc))
print(t0, ' ', d, ' ', az)
self.text.write('{} {}\n'.format(d, az))
t0 = t0 + dt
def __del__(self):
self.text.close()
rls = Information(0.0, 0.0, 150.0, [ # TAircraft(150.0, 40.0, 30.0, 10.0),
TMissile(-100.0, 250.0, 90.0, 25.0, 2.0)])
rls.peleng(0, 1000.0)
Supports Markdown
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