Commit 5b4d128d authored by IDUshakov's avatar IDUshakov
Browse files

Delete TLibrary.txt

parent 5e072da2
#include <cmath>
#include <vector>
#include <string>
const double PI = 3.141592653589793238463;
const double dt = 1;
const long N = 10;
class TAObject
{
public:
double x, y;
bool f;
TAObject(const double, const double);
~TAObject() = default;
};
class TLA: public TAObject
{
private:
void takeB();
public:
std::string type;
double xc, yc, R, phi, V, b;
bool landing;
TLA(double x, double y, double V, double xe, double ye);
virtual bool move(double t, int a);
};
class TAircraft : public TLA
{
public:
bool move(double t, int a) override;
};
class THelicopter : public TLA
{
public:
bool move(double t, int a) override;
};
class TAirport : public TAObject
{
public:
double l;
std::vector<TLA> LA;
TAirport(double x, double y, double l);
void Do(double t0, double tk);
};
TAObject::TAObject(const double x, const double y)
{
this->x = x;
this->y = y;
}
TAObject::~TAObject() {}
TLA::TLA(double x, double y, double V, double xe, double ye) : TAObject(x, y)
{
/* this->x = x;
this->y = y; */
this->V = V;
this->xc = xc;
this->yc = yc;
this->R = sqrt(pow((x - xc), 2) + pow((y - yc), 2));
takeB();
this->phi = b*PI + atan((y - yc)/(x -xc));
}
void TLA::takeB()
{
if (this->x > this->xc) {
this-> b = 0;
} else if (this->x < this->xc && this->y < this->yc) {
this->b = -1;
} else if (this->x < this-> xc && this->y > this->yc) {
this->b = 1;
}
}
bool TLA::move(double t, int a)
{
if (a) {
return true;
} else {
return false;
}
}
bool TAircraft::move(double t, int a)
{
double sigma = (0 - this->V)/this->R;
this->x = -(this->xc + this->R * cos(this->phi + sigma*t)) * (a - 1) + a * (this->x + this->x + this->V * dt); this->y = -(this->yc + this->R * sin(this->phi + sigma * t)) * (a -1) + y * a;
this->type = "A";
return true;
}
bool THelicopter::move(double t, int a)
{
this->x = this->x - a*this->V*cos(this->phi)*dt;
this->y = this->y - a*this->V*sin(this->phi)*dt;
this->type = "H";
return true;
}
TAirport::TAirport(double x, double y, double l) : TAObject(x, y)
{
this->l = l;
}
void TAirport::Do(double t0, double tk)
{
for (int i = t0; i <= tk; i += dt) {
double X = x + 1.1*l;
double a;
if (LA[i].type == "A") {
if (!(f & LA[i].f) & LA[i].x < X & abs(LA[i].y - y) < l/50) {
a = 1;
} else {
a = 0;
}
if (LA[i].x > (x + l) & LA[i].f) {
LA[i].landing = true;
} else {
LA[i].landing = false;
}
} else if (LA[i].type == "H") {
if (!(f & !LA[i].f)) {
a = 1;
} else {
a = 0;
}
if (pow((LA[i].x - x), 2) + pow((LA[i].y - y), 2) < pow((l/50), 2) & LA[i].f) {
LA[i].landing = true;
} else {
LA[i].landing = false;
}
}
}
}
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