92 lines
1.7 KiB
C++
92 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "mcc_coord.h"
|
|
|
|
namespace mcc
|
|
{
|
|
class MccProhibitedZone
|
|
{
|
|
public:
|
|
virtual ~MccProhibitedZone() = default;
|
|
|
|
bool inZone(this auto&& self, const MccCoordinate& x, const MccCoordinate& y)
|
|
{
|
|
return std::forward<decltype(self)>(self).inZoneImpl(x, y);
|
|
}
|
|
|
|
protected:
|
|
bool inZoneImpl(const MccCoordinate&, const MccCoordinate&)
|
|
{
|
|
return false;
|
|
}
|
|
};
|
|
|
|
class MccMinAltPZ : public MccProhibitedZone
|
|
{
|
|
public:
|
|
MccMinAltPZ(const MccCoordinate& min_alt) : _minAlt(min_alt) {}
|
|
|
|
MccCoordinate minAlt() const
|
|
{
|
|
return _minAlt;
|
|
}
|
|
|
|
private:
|
|
double _minAlt;
|
|
|
|
bool inZoneImpl(const MccCoordinate& alt, const MccCoordinate&)
|
|
{
|
|
return alt <= _minAlt;
|
|
}
|
|
};
|
|
|
|
|
|
class MccMaxAltPZ
|
|
{
|
|
public:
|
|
MccMaxAltPZ(double max_alt) : _maxAlt(max_alt) {}
|
|
|
|
double maxAlt() const
|
|
{
|
|
return _maxAlt;
|
|
}
|
|
|
|
private:
|
|
double _maxAlt;
|
|
|
|
bool inZoneImpl(const MccCoordinate& alt, const MccCoordinate&)
|
|
{
|
|
return alt >= _maxAlt;
|
|
}
|
|
};
|
|
|
|
|
|
class MccElliipsePZ
|
|
{
|
|
public:
|
|
MccElliipsePZ(const MccCoordinate& xc, const MccCoordinate& yc, const MccCoordinate& a, const MccCoordinate& b)
|
|
: _xc(xc), _yc(yc), _a(a), _b(b), _a2(a * a), _b2(b * b)
|
|
{
|
|
}
|
|
|
|
// circle
|
|
MccElliipsePZ(const MccCoordinate& xc, const MccCoordinate& yc, const MccCoordinate& a)
|
|
: mcc::MccElliipsePZ(xc, yc, a, a)
|
|
{
|
|
}
|
|
|
|
|
|
private:
|
|
double _xc, _yc, _a, _b, _a2, _b2;
|
|
|
|
bool inZoneImpl(const MccCoordinate& alt, const MccCoordinate& zd)
|
|
{
|
|
auto x2 = alt - _xc;
|
|
auto y2 = zd - _yc;
|
|
|
|
return (x2 * x2 / _a2 + y2 * y2 / _b2) <= 1.0;
|
|
}
|
|
};
|
|
|
|
} // namespace mcc
|