227 lines
7.9 KiB
C
227 lines
7.9 KiB
C
|
#include <cmath>
|
||
|
#include <complex>
|
||
|
#include <cstddef>
|
||
|
#include <cstdlib>
|
||
|
#include <functional>
|
||
|
#include <iomanip>
|
||
|
#include <limits>
|
||
|
#include <math.h>
|
||
|
#include <numbers>
|
||
|
#include <string_view>
|
||
|
#include <vector>
|
||
|
|
||
|
#define M_Pi 3.14159265358979323846
|
||
|
|
||
|
const float PDBt[] = {
|
||
|
1, 0.9996547, 0.9986309, 0.9969996, 0.9947753, 0.992019,
|
||
|
0.9887693, 0.9850653, 0.9809683, 0.9765174, 0.971751, 0.9667184,
|
||
|
0.9614573, 0.9560267, 0.9504516, 0.9447785, 0.9390528, 0.9333188,
|
||
|
0.9275984, 0.9219344, 0.9163682, 0.9109405, 0.9056805, 0.9006271,
|
||
|
0.8958081, 0.8912509, 0.8869824, 0.8829681, 0.8791338, 0.8754372,
|
||
|
0.8718264, 0.8682404, 0.8646393, 0.860964, 0.8571661, 0.8531983,
|
||
|
0.8490143, 0.8445687, 0.839808, 0.8346896, 0.8291822, 0.8232277,
|
||
|
0.8168081, 0.8098694, 0.8023891, 0.7943282, 0.7856697, 0.7763812,
|
||
|
0.7664432, 0.7558489, 0.7445777, 0.7326305, 0.7200042, 0.7066999,
|
||
|
0.6927157, 0.6780707, 0.662781, 0.646867, 0.6303547, 0.6132747,
|
||
|
0.5956622, 0.5774907, 0.5584638, 0.5382822, 0.5167018, 0.4935714,
|
||
|
0.468808, 0.442405, 0.4144718, 0.3851855, 0.3548133, 0.3237017,
|
||
|
0.2922504, 0.2609126, 0.2301495, 0.200431, 0.1721929, 0.1458194,
|
||
|
0.121624, 0.09983687, 0.08058908, 0.06391948, 0.0497765, 0.03802762,
|
||
|
0.02847982, 0.02089019, 0.01499667, 0.01053091, 0.007224957, 0.004837355,
|
||
|
0.003162278};
|
||
|
const float PDEp[] = {
|
||
|
1, 0.9996316, 0.9985504, 0.9968045, 0.9944203, 0.9914481,
|
||
|
0.9879273, 0.9838978, 0.9793998, 0.9744846, 0.9691924, 0.9635517,
|
||
|
0.9576239, 0.9514369, 0.9450287, 0.9384475, 0.9317298, 0.9249111,
|
||
|
0.9180366, 0.9111293, 0.9042219, 0.8973668, 0.890574, 0.8838936,
|
||
|
0.8773442, 0.8709636, 0.8647489, 0.8585884, 0.8523442, 0.8458824,
|
||
|
0.8390831, 0.8318213, 0.8239674, 0.8154268, 0.8060834, 0.7958478,
|
||
|
0.7846211, 0.7723337, 0.758927, 0.7443291, 0.7285175, 0.7114592,
|
||
|
0.6931624, 0.6736201, 0.6528674, 0.6309574, 0.607974, 0.5841374,
|
||
|
0.5596867, 0.5348352, 0.5097944, 0.4847524, 0.4598857, 0.4353415,
|
||
|
0.4112633, 0.3877663, 0.3649471, 0.3428861, 0.3216511, 0.3012902,
|
||
|
0.2818383, 0.2632964, 0.2455697, 0.2285625, 0.2121999, 0.1964332,
|
||
|
0.1812278, 0.1665692, 0.1524526, 0.1388895, 0.1258924, 0.1134879,
|
||
|
0.101702, 0.09056489, 0.08010306, 0.07034202, 0.06130171, 0.05299528,
|
||
|
0.04542796, 0.03859663, 0.03248846, 0.02707951, 0.02234502, 0.01824281,
|
||
|
0.01473092, 0.0117601, 0.009273618, 0.007224957, 0.005558777, 0.004219005,
|
||
|
0.003162278};
|
||
|
|
||
|
const double KDeg = 57.295779513;
|
||
|
|
||
|
struct TPoint3D {
|
||
|
TPoint3D() {}
|
||
|
TPoint3D(float x, float y, float z) : X(x), Y(y), Z(z) {}
|
||
|
|
||
|
float X = 0;
|
||
|
float Y = 0;
|
||
|
float Z = 0;
|
||
|
};
|
||
|
|
||
|
struct TIzl {
|
||
|
TIzl() {}
|
||
|
TIzl(TPoint3D pos, float amp, float fase) : IzPos(pos), Amplitude(amp), Fase(fase) {}
|
||
|
|
||
|
TPoint3D IzPos = TPoint3D();
|
||
|
float Amplitude = 0;
|
||
|
float Fase = 0;
|
||
|
};
|
||
|
|
||
|
class TRadar {
|
||
|
|
||
|
public:
|
||
|
const double FZAntena = 0.7; // половина антены по оси Z в м
|
||
|
const double FYAntena = 0.4; // половина антены по оси Y в м
|
||
|
const double FZYA = FZAntena * FYAntena; // Вспомогательная величина характеризующая геометрию антены
|
||
|
const double FLym = 0.03;
|
||
|
const double FKLym = M_Pi * 2 / FLym;
|
||
|
const double FStepZ = 0.017;
|
||
|
const double FStepY = 0.023;
|
||
|
const double FPowerValue = 0.75;
|
||
|
const double FKof132 = 1.32;
|
||
|
|
||
|
std::vector<TIzl> FIzlArray;
|
||
|
|
||
|
std::complex<double> FSum, FAz, FUm;
|
||
|
double FSumAmp, FAzAmp, FUmAmp;
|
||
|
|
||
|
double GetAmpOneIzl(float tet, float fi);
|
||
|
TIzl GetIzl(int i);
|
||
|
|
||
|
void FillArrayIzl(); // FillArrayIzl1
|
||
|
|
||
|
TRadar();
|
||
|
~TRadar();
|
||
|
|
||
|
void GetAmplituds(float tet, float fi, float offsetTet, float offsetFi);
|
||
|
|
||
|
std::vector<TIzl> Izls() const { return this->FIzlArray; }
|
||
|
double GetSumAmp() const { return this->FSumAmp; }
|
||
|
double GetAzAmp() const { return this->FAzAmp; }
|
||
|
double GetUmAmp() const { return this->FUmAmp; }
|
||
|
std::complex<double> GetSum() const { return this->FSum; }
|
||
|
std::complex<double> GetAz() const { return this->FAz; }
|
||
|
std::complex<double> GetUm() const { return this->FUm; }
|
||
|
};
|
||
|
|
||
|
inline TRadar::TRadar() {
|
||
|
this->FillArrayIzl();
|
||
|
}
|
||
|
|
||
|
inline TRadar::~TRadar() {}
|
||
|
|
||
|
inline double frac(double t) { return t - floor(t); }
|
||
|
|
||
|
inline double TRadar::GetAmpOneIzl(float tet, float fi) {
|
||
|
int i;
|
||
|
std::complex<double> wc{};
|
||
|
|
||
|
wc.real(std::abs(tet * KDeg));
|
||
|
i = std::trunc(wc.real());
|
||
|
wc.real(PDBt[i] + frac(wc.real()) * (PDBt[i + 1] - PDBt[i]));
|
||
|
|
||
|
wc.imag(fi * KDeg);
|
||
|
i = std::trunc(wc.imag());
|
||
|
wc.imag(PDEp[i] + frac(wc.real()) * (PDEp[i + 1] - PDEp[i]));
|
||
|
|
||
|
return wc.real() * wc.imag();
|
||
|
}
|
||
|
|
||
|
inline void TRadar::GetAmplituds(float tet, float fi, float offsetTet,
|
||
|
float offsetFi) {
|
||
|
double pda = GetAmpOneIzl(offsetTet, offsetFi);
|
||
|
|
||
|
tet = (std::sin(offsetTet) * std::cos(offsetFi) -
|
||
|
std::sin(tet) * std::cos(fi)) *
|
||
|
FKLym;
|
||
|
fi = (std::sin(offsetFi) * std::sin(fi)) * FKLym;
|
||
|
|
||
|
std::complex<double> us[4]{};
|
||
|
|
||
|
int c;
|
||
|
|
||
|
for (int i = 0; i < FIzlArray.size(); i++) {
|
||
|
auto Izl = FIzlArray[i];
|
||
|
Izl.Fase = Izl.IzPos.Z * tet + Izl.IzPos.Y * fi;
|
||
|
|
||
|
c = i % 4;
|
||
|
us[c].real(us[c].real() + Izl.Amplitude * std::cos(Izl.Fase));
|
||
|
us[c].imag(us[c].imag() + Izl.Amplitude * std::sin(Izl.Fase));
|
||
|
}
|
||
|
|
||
|
FSum.real((us[0].real() + us[1].real() + us[2].real() + us[3].real()) * pda);
|
||
|
FSum.imag((us[0].imag() + us[1].imag() + us[2].imag() + us[3].imag()) * pda);
|
||
|
|
||
|
FAz.real((us[1].real() + us[2].real() + us[3].real() + us[0].real()) * pda);
|
||
|
FAz.imag((us[1].imag() + us[2].imag() + us[3].imag() + us[0].imag()) * pda);
|
||
|
|
||
|
FUm.real((us[2].real() + us[3].real() + us[0].real() + us[1].real()) * pda);
|
||
|
FUm.imag((us[2].imag() + us[3].imag() + us[0].imag() + us[1].imag()) * pda);
|
||
|
|
||
|
FSumAmp = std::abs(FSum);
|
||
|
FAzAmp = std::abs(FAz);
|
||
|
FUmAmp = std::abs(FUm);
|
||
|
}
|
||
|
|
||
|
inline void TRadar::FillArrayIzl() {
|
||
|
const int
|
||
|
IzCountZ = 72, // Кол-во излучателей по оси Z ( Если предпологать, что антена прямоугольная )
|
||
|
IzCountY = 35; // Кол-во излучателей по оси Y ( Если предпологать, что антена прямоугольная )
|
||
|
const double
|
||
|
OfZ =-FStepZ*0.5-35*FStepZ,
|
||
|
OfY =-FStepY*0.25-17*FStepY;
|
||
|
|
||
|
std::vector<TIzl> U1, U2, U3, U4;
|
||
|
|
||
|
for (int i = 0; i < IzCountY-1; i++) {
|
||
|
for (int j = 0; j < IzCountZ-1; j++) {
|
||
|
float z = OfY+j*FStepZ;
|
||
|
float y;
|
||
|
if (j%2 == 0) {
|
||
|
y = OfY+FStepY*i;
|
||
|
} else {
|
||
|
y = OfY+FStepY*(i+0.5);
|
||
|
}
|
||
|
|
||
|
float r = 1;
|
||
|
|
||
|
if (z>0) {
|
||
|
if (y>0) {
|
||
|
U1.push_back(TIzl(TPoint3D(0, y, z), r, 0));
|
||
|
} else {
|
||
|
U4.push_back(TIzl(TPoint3D(0, y, z), r, 0));
|
||
|
}
|
||
|
} else {
|
||
|
if (y>0) {
|
||
|
U2.push_back(TIzl(TPoint3D(0, y, z), r, 0));
|
||
|
} else {
|
||
|
U3.push_back(TIzl(TPoint3D(0, y, z), r, 0));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int maxLen = U1.size();
|
||
|
if (U2.size()>maxLen) {
|
||
|
maxLen = U2.size();
|
||
|
}
|
||
|
if (U3.size()>maxLen) {
|
||
|
maxLen = U3.size();
|
||
|
}
|
||
|
if (U4.size()>maxLen) {
|
||
|
maxLen = U4.size();
|
||
|
}
|
||
|
|
||
|
U1.resize(maxLen, TIzl(TPoint3D(0, 0, 0), 0, 0));
|
||
|
U2.resize(maxLen, TIzl(TPoint3D(0, 0, 0), 0, 0));
|
||
|
U3.resize(maxLen, TIzl(TPoint3D(0, 0, 0), 0, 0));
|
||
|
U4.resize(maxLen, TIzl(TPoint3D(0, 0, 0), 0, 0));
|
||
|
|
||
|
for (int i = 0; i < maxLen; i++) {
|
||
|
this->FIzlArray.push_back(U1[i]);
|
||
|
this->FIzlArray.push_back(U2[i]);
|
||
|
this->FIzlArray.push_back(U3[i]);
|
||
|
this->FIzlArray.push_back(U4[i]);
|
||
|
}
|
||
|
}
|