776 lines
21 KiB
C++
776 lines
21 KiB
C++
|
#include "stdafx.h"
|
|||
|
#include "SARSatelliteSimulationAbstractCls.h"
|
|||
|
#include <Eigen/Core>
|
|||
|
#include <Eigen/Dense>
|
|||
|
#include <QDebug>
|
|||
|
#include <QFile>
|
|||
|
#include <QDomDocument>
|
|||
|
#include <QDateTime>
|
|||
|
#include <QString>
|
|||
|
#include "BaseTool.h"
|
|||
|
#include <QCoreApplication>
|
|||
|
#include <QFile>
|
|||
|
#include <QTextStream>
|
|||
|
#include <QStringList>
|
|||
|
#include <QDebug>
|
|||
|
#include <vector>
|
|||
|
#include <unordered_map>
|
|||
|
|
|||
|
|
|||
|
AbstractSatelliteOribtModel::~AbstractSatelliteOribtModel()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
SatelliteOribtNode AbstractSatelliteOribtModel::getSatelliteOribtNode(double& timeFromStartTime, bool& antAzAngleFlag)
|
|||
|
{
|
|||
|
return SatelliteOribtNode();
|
|||
|
}
|
|||
|
|
|||
|
ErrorCode AbstractSatelliteOribtModel::getSatelliteOribtNode(double& timeFromStartTime, SatelliteOribtNode& node, bool& antAzAngleFlag)
|
|||
|
{
|
|||
|
return ErrorCode::VIRTUALABSTRACT;
|
|||
|
}
|
|||
|
|
|||
|
ErrorCode AbstractSatelliteOribtModel::getSatelliteAntDirectNormal(SatelliteOribtNode& Rs, Vector3D& Rt, SatelliteAntDirect& antNode)
|
|||
|
{
|
|||
|
return ErrorCode();
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSatelliteOribtModel::setSatelliteOribtStartTime(long double oribtRefrenceTime)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
long double AbstractSatelliteOribtModel::getSatelliteOribtStartTime()
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
void AbstractSatelliteOribtModel::setbeamAngle(double beamAngle, bool RightLook)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSatelliteOribtModel::setAzAngleRange(double cycletime, double minAzAngle, double maxAzAngle, double referenceAzAngle, double referenceTimeFromStartTime)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSatelliteOribtModel::getAzAngleInCurrentTimeFromStartTime(double& currentTime)
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
ErrorCode AbstractSatelliteOribtModel::getAzAngleInCurrentTimeFromStartTime(double& currentTime, double& AzAngle)
|
|||
|
{
|
|||
|
return ErrorCode::VIRTUALABSTRACT;
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSatelliteOribtModel::setAntnnaAxisX(double X, double Y, double Z)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSatelliteOribtModel::setAntnnaAxisY(double X, double Y, double Z)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSatelliteOribtModel::setAntnnaAxisZ(double X, double Y, double Z)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
ErrorCode AbstractSatelliteOribtModel::getAntnnaDirection(SatelliteOribtNode& node)
|
|||
|
{
|
|||
|
return ErrorCode::VIRTUALABSTRACT;
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSatelliteOribtModel::getPt()
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSatelliteOribtModel::getGri()
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSatelliteOribtModel::setPt(double Pt)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSatelliteOribtModel::setGri(double gri)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
SatelliteOribtNode AbstractSARSatelliteModel::getSatelliteOribtNode(double& timeFromStartTime, bool& antAzAngleFlag)
|
|||
|
{
|
|||
|
return SatelliteOribtNode();
|
|||
|
}
|
|||
|
|
|||
|
ErrorCode AbstractSARSatelliteModel::getSatelliteOribtNode(double& timeFromStartTime, SatelliteOribtNode& node, bool& antAzAngleFlag)
|
|||
|
{
|
|||
|
return ErrorCode();
|
|||
|
}
|
|||
|
|
|||
|
ErrorCode AbstractSARSatelliteModel::getSatelliteAntDirectNormal(SatelliteOribtNode& Rs, Vector3D& Rt, SatelliteAntDirect& antNode)
|
|||
|
{
|
|||
|
return ErrorCode();
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setSatelliteOribtModel(std::shared_ptr<AbstractSatelliteOribtModel> model)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setSARImageStartTime(long double imageStartTime)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setSARImageEndTime(long double imageEndTime)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getSARImageStartTime()
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getSARImageEndTime()
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getNearRange()
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setNearRange(double NearRange)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getFarRange()
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setFarRange(double FarRange)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
bool AbstractSARSatelliteModel::getIsRightLook()
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setIsRightLook(bool isR)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setCenterFreq(double Freq)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getCenterFreq()
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setCenterLamda(double Lamda)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getCenterLamda()
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setBandWidth(double bandwidth)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getBandWidth()
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
POLARTYPEENUM AbstractSARSatelliteModel::getPolarType()
|
|||
|
{
|
|||
|
return POLARTYPEENUM();
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setPolarType(POLARTYPEENUM type)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setPRF(double prf)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getPRF()
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getFs()
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setFs(double Fs)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getCenterLookAngle()
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setCenterLookAngle(double angle)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setTransformRadiationPattern(std::shared_ptr<AbstractRadiationPattern> radiationPanttern)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setReceiveRadiationPattern(std::shared_ptr<AbstractRadiationPattern> radiationPanttern)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
std::shared_ptr<AbstractRadiationPattern> AbstractSARSatelliteModel::getTransformRadiationPattern()
|
|||
|
{
|
|||
|
return std::shared_ptr<AbstractRadiationPattern>();
|
|||
|
}
|
|||
|
|
|||
|
std::shared_ptr<AbstractRadiationPattern> AbstractSARSatelliteModel::getReceiveRadiationPattern()
|
|||
|
{
|
|||
|
return std::shared_ptr<AbstractRadiationPattern>();
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getPt()
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
double AbstractSARSatelliteModel::getGri()
|
|||
|
{
|
|||
|
return 0.0;
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setPt(double Pt)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void AbstractSARSatelliteModel::setGri(double gri)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
ErrorCode ReadSateGPSPointsXML(QString xmlPath, std::vector<SatelliteOribtNode>& nodes)
|
|||
|
{
|
|||
|
// <20><>ȡ<EFBFBD>ļ<EFBFBD>
|
|||
|
QFile file(xmlPath);
|
|||
|
if (!file.open(QIODevice::ReadOnly)) {
|
|||
|
qDebug() << "Cannot open file for reading.";
|
|||
|
return ErrorCode::FILEOPENFAIL;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
QDomDocument doc;
|
|||
|
if (!doc.setContent(&file)) {
|
|||
|
qDebug() << "Failed to parse the XML.";
|
|||
|
file.close();
|
|||
|
return ErrorCode::XMLPARSEFAIL;
|
|||
|
}
|
|||
|
file.close();
|
|||
|
|
|||
|
QDomElement root = doc.documentElement();
|
|||
|
QDomNodeList gpsParamList = root.firstChildElement("GPS").elementsByTagName("GPSParam");
|
|||
|
nodes.clear();
|
|||
|
for (int i = 0; i < gpsParamList.size(); ++i) {
|
|||
|
QDomElement gpsParam = gpsParamList.at(i).toElement();
|
|||
|
|
|||
|
QDomElement timeStampElement = gpsParam.firstChildElement("TimeStamp");
|
|||
|
QDomElement xPositionElement = gpsParam.firstChildElement("xPosition");
|
|||
|
QDomElement yPositionElement = gpsParam.firstChildElement("yPosition");
|
|||
|
QDomElement zPositionElement = gpsParam.firstChildElement("zPosition");
|
|||
|
QDomElement xVelocityElement = gpsParam.firstChildElement("xVelocity");
|
|||
|
QDomElement yVelocityElement = gpsParam.firstChildElement("yVelocity");
|
|||
|
QDomElement zVelocityElement = gpsParam.firstChildElement("zVelocity");
|
|||
|
|
|||
|
if (timeStampElement.isNull() ||
|
|||
|
xPositionElement.isNull() || yPositionElement.isNull() || zPositionElement.isNull() ||
|
|||
|
xVelocityElement.isNull() ||yVelocityElement.isNull() ||zVelocityElement.isNull()) {
|
|||
|
nodes.clear();
|
|||
|
return ErrorCode::XMLNOTFOUNDElEMENT;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
QString timeStamp = timeStampElement.text();
|
|||
|
QString xPosition = xPositionElement.text();
|
|||
|
QString yPosition = yPositionElement.text();
|
|||
|
QString zPosition = zPositionElement.text();
|
|||
|
QString xVelocity = xVelocityElement.text();
|
|||
|
QString yVelocity = yVelocityElement.text();
|
|||
|
QString zVelocity = zVelocityElement.text();
|
|||
|
|
|||
|
// ת<><D7AA>
|
|||
|
|
|||
|
long double timestamp = convertToMilliseconds(timeStamp.toStdString());
|
|||
|
SatelliteOribtNode node;
|
|||
|
node.time = timestamp;
|
|||
|
node.Px = xPosition.toDouble();
|
|||
|
node.Py = yPosition.toDouble();
|
|||
|
node.Pz = zPosition.toDouble();
|
|||
|
node.Vx = xVelocity.toDouble();
|
|||
|
node.Vy = yVelocity.toDouble();
|
|||
|
node.Vz = zVelocity.toDouble();
|
|||
|
|
|||
|
nodes.push_back(node);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
qDebug() << "--- GPS Node Extracted -----------------------------------------------------------";
|
|||
|
qDebug() << "time\tPx\tPy\tPz\tVx\tVy\tVz";
|
|||
|
for (int i = 0; i < nodes.size(); ++i) {
|
|||
|
SatelliteOribtNode node= nodes[i];
|
|||
|
// <20><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
qDebug() << (double)node.time << "\t" << node.Px << "\t" << node.Py << "\t" << node.Pz << "\t" << node.Vx << "\t" << node.Vy << "\t" << node.Vz;
|
|||
|
|
|||
|
}
|
|||
|
qDebug() << "\n\n\n";
|
|||
|
|
|||
|
return ErrorCode::SUCCESS;
|
|||
|
}
|
|||
|
|
|||
|
std::vector<SatelliteOribtNode> FilterSatelliteOribtNode(std::vector<SatelliteOribtNode>& nodes, double startTime, double endTime, long minCount)
|
|||
|
{
|
|||
|
if (minCount < nodes.size()) {
|
|||
|
return std::vector<SatelliteOribtNode>(0);
|
|||
|
}
|
|||
|
else {}
|
|||
|
|
|||
|
std::vector<double> dtime(nodes.size());
|
|||
|
double centerTime = startTime + (endTime-startTime) / 2.0;
|
|||
|
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD> С --> <20><>
|
|||
|
std::sort(nodes.begin(), nodes.end(), [](SatelliteOribtNode& a, SatelliteOribtNode& b) {
|
|||
|
return a.time < b.time;
|
|||
|
});
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
for (long i = 0; i < nodes.size(); i++) {
|
|||
|
dtime[i] =std::abs(nodes[i].time - centerTime);
|
|||
|
}
|
|||
|
|
|||
|
// find min value idx
|
|||
|
long minIdx = 0;
|
|||
|
double min = dtime[0];
|
|||
|
for (long i = 1; i < nodes.size(); i++) {
|
|||
|
if (dtime[i] < min) {
|
|||
|
min = (dtime[i]);
|
|||
|
minIdx = i;
|
|||
|
}
|
|||
|
else {}
|
|||
|
}
|
|||
|
std::vector<SatelliteOribtNode> result(0);
|
|||
|
// <20><><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>
|
|||
|
long left = minIdx;
|
|||
|
long right = minIdx+1;
|
|||
|
while (left >= 0 || right < nodes.size()) {
|
|||
|
// <20><><EFBFBD>Ҽ<EFBFBD><D2BC><EFBFBD>
|
|||
|
if (left >= 0) {
|
|||
|
result.push_back(nodes[left]);
|
|||
|
}
|
|||
|
else {}
|
|||
|
left--;
|
|||
|
|
|||
|
if (right < nodes.size()) {
|
|||
|
result.push_back(nodes[right]);
|
|||
|
}
|
|||
|
else {}
|
|||
|
right++;
|
|||
|
|
|||
|
if (result.size() > minCount) {
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
std::shared_ptr<AbstractRadiationPattern> CreateAbstractRadiationPattern(std::vector<RadiationPatternGainPoint> antPatternPoints)
|
|||
|
{
|
|||
|
std::shared_ptr<AbstractRadiationPattern> pattern = std::make_shared<AbstractRadiationPattern>();
|
|||
|
for (long i = 0; i < antPatternPoints.size(); i++) {
|
|||
|
RadiationPatternGainPoint point = antPatternPoints[i];
|
|||
|
pattern->setGain(point.theta, point.phi, point.GainValue);
|
|||
|
|
|||
|
}
|
|||
|
pattern->RecontructGainMatrix();
|
|||
|
|
|||
|
return pattern;
|
|||
|
}
|
|||
|
|
|||
|
std::vector<RadiationPatternGainPoint> ReadGainFile(QString antPatternFilePath)
|
|||
|
{
|
|||
|
std::vector<RadiationPatternGainPoint> dataPoints(0);
|
|||
|
QFile file(antPatternFilePath);
|
|||
|
|
|||
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|||
|
qDebug() << "Failed to open the file.";
|
|||
|
return dataPoints; // <20><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
QTextStream in(&file);
|
|||
|
QStringList headers = in.readLine().split(","); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
qDebug() << "Headers:" << headers;
|
|||
|
if (headers.count() < 3) {
|
|||
|
file.close();
|
|||
|
return dataPoints;
|
|||
|
}
|
|||
|
qDebug() << "parase ant radiation pattern contains ";
|
|||
|
long theta_id = -1;
|
|||
|
long phi_id = -1;
|
|||
|
long gain_id = -1;
|
|||
|
for (long i = 0; i < headers.size(); i++) {
|
|||
|
if (headers[i].toLower().contains("theta")) {
|
|||
|
theta_id = i;
|
|||
|
}
|
|||
|
else if (headers[i].toLower().contains("phi")) {
|
|||
|
phi_id = i;
|
|||
|
}
|
|||
|
else if (headers[i].toLower().contains("gain")) {
|
|||
|
gain_id = i;
|
|||
|
}
|
|||
|
}
|
|||
|
if (theta_id == -1 || phi_id == -1 || gain_id == -1) {
|
|||
|
qDebug() << "Failed to find the field.";
|
|||
|
file.close();
|
|||
|
return dataPoints; // <20><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
QString line = "";
|
|||
|
do{
|
|||
|
|
|||
|
QString line = in.readLine();
|
|||
|
if (line.isNull()) {
|
|||
|
break;
|
|||
|
}
|
|||
|
if (line.isEmpty()) {
|
|||
|
continue;
|
|||
|
}
|
|||
|
QStringList fields = line.split(",");
|
|||
|
if (fields.size() >=3) {
|
|||
|
if (fields[0].isEmpty()) {
|
|||
|
continue;
|
|||
|
}
|
|||
|
RadiationPatternGainPoint point{0,0,0};
|
|||
|
bool thetaflag = false;
|
|||
|
bool phiflag = false;
|
|||
|
bool gainflag = false;
|
|||
|
point.theta = fields[theta_id].toDouble(&thetaflag); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><D6A3>ᵼ<EFBFBD>³<EFBFBD><C2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
point.phi = fields[phi_id].toDouble(&phiflag);
|
|||
|
point.GainValue = fields[gain_id].toDouble(&gainflag);
|
|||
|
if (!(thetaflag && phiflag && gainflag)) {
|
|||
|
file.close();
|
|||
|
return std::vector< RadiationPatternGainPoint>(0);
|
|||
|
}
|
|||
|
// <20>Ƕ<EFBFBD>ת<EFBFBD><D7AA>Ϊ -180 ~ 180
|
|||
|
|
|||
|
point.theta = point.theta > 180 ? point.theta - 360 : point.theta;
|
|||
|
point.phi = point.phi > 180 ? point.phi - 360 : point.phi;
|
|||
|
|
|||
|
dataPoints.push_back(point);
|
|||
|
}
|
|||
|
else {}
|
|||
|
} while (!line.isNull());
|
|||
|
qDebug() << "over";
|
|||
|
|
|||
|
file.close();
|
|||
|
return dataPoints;
|
|||
|
}
|
|||
|
|
|||
|
double getDopplerCenterFreq(double& lamda, double& R, Vector3D& Rs, Vector3D& Rt, Vector3D& Vs, Vector3D& Vt)
|
|||
|
{
|
|||
|
return ( - 2 / lamda) * dot(Rs - Rt, Vs - Vt) / R; // <20><><EFBFBD>غϳɿ<C9BF><D7BE>״<EFBFBD>ԭʼ<D4AD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>о<EFBFBD> 3.18
|
|||
|
}
|
|||
|
|
|||
|
double getDopplerFreqRate(double& lamda, double& R, Vector3D& Rs, Vector3D& Rt, Vector3D& Vs, Vector3D& Vt, Vector3D& Ast)
|
|||
|
{
|
|||
|
return -(2/lamda)*(dot(Vs - Vt, Vs - Vt)/R+ dot(Ast, Rs - Rt) /R- std::pow(dot(Vs - Vt, Rs - Rt),2 )/std::pow(R,3));// <20><><EFBFBD>غϳɿ<C9BF><D7BE>״<EFBFBD>ԭʼ<D4AD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>о<EFBFBD> 3.19
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
AbstractRadiationPattern::AbstractRadiationPattern()
|
|||
|
{
|
|||
|
this->GainMap = std::vector<RadiationPatternGainPoint>(0);
|
|||
|
this->thetas = std::vector<double>(0);
|
|||
|
this->phis = std::vector<double>(0);
|
|||
|
this->GainMatrix = Eigen::MatrixXd(0, 0);
|
|||
|
}
|
|||
|
|
|||
|
AbstractRadiationPattern::~AbstractRadiationPattern()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
double AbstractRadiationPattern::getGain(double& theta, double& phi )
|
|||
|
{
|
|||
|
double gainValue = 0;
|
|||
|
ErrorCode state = getGain(theta, phi, gainValue);
|
|||
|
return gainValue;
|
|||
|
}
|
|||
|
|
|||
|
std::vector<RadiationPatternGainPoint> AbstractRadiationPattern::getGainList()
|
|||
|
{
|
|||
|
return this->GainMap;
|
|||
|
}
|
|||
|
|
|||
|
ErrorCode AbstractRadiationPattern::getGain(double& theta, double& phi, double& GainValue)
|
|||
|
{
|
|||
|
if (this->mintheta > theta || this->maxtheta<theta || this->minphi>phi || this->maxphi < phi) {
|
|||
|
GainValue = 0;
|
|||
|
return ErrorCode::OUTOFRANGE;
|
|||
|
}
|
|||
|
|
|||
|
if (theta>=0&&std::sin(theta * d2r)*std::cos(phi*d2r) > this->EdgeXMax) { // Խ<><D4BD>
|
|||
|
GainValue = 0;
|
|||
|
return ErrorCode::OUTOFRANGE;
|
|||
|
}
|
|||
|
if (theta < 0 && -1*std::sin(theta * d2r) * std::cos(phi * d2r) < this->EdgeXMin) {
|
|||
|
GainValue = 0;
|
|||
|
return ErrorCode::OUTOFRANGE;
|
|||
|
}
|
|||
|
|
|||
|
// <20><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (this->GainMap.size() == 0) { // ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>
|
|||
|
GainValue = 1;
|
|||
|
}
|
|||
|
else {
|
|||
|
// --˫<><CBAB><EFBFBD>Բ<EFBFBD>ֵ
|
|||
|
if (this->GainMatrix.rows() != this->phis.size() || this->GainMatrix.cols() != this->thetas.size()) {
|
|||
|
this->RecontructGainMatrix();
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD>˫<EFBFBD><CBAB><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
long lasttheta = FindValueInStdVectorLast(this->thetas,theta);
|
|||
|
long nextTheta = lasttheta+1;
|
|||
|
long lastphi = FindValueInStdVectorLast(this->phis, phi);;
|
|||
|
long nextPhi = lastphi+1;
|
|||
|
|
|||
|
if (lasttheta == -1 || nextTheta == -1 || lastphi == -1 || nextPhi == -1) {
|
|||
|
return ErrorCode::FIND_ID_ERROR;
|
|||
|
}
|
|||
|
double x1 = this->thetas[lasttheta];
|
|||
|
double x2 = this->thetas[nextTheta];
|
|||
|
double y1 = this->phis[lastphi];
|
|||
|
double y2 = this->phis[nextPhi];
|
|||
|
//double z11 = this->GainMatrix(lasttheta, lastphi);//std::pow(10,this->GainMatrix(lasttheta, lastphi)/10);
|
|||
|
//double z12 = this->GainMatrix(lasttheta, nextPhi);//std::pow(10,this->GainMatrix(lasttheta, nextPhi)/10);
|
|||
|
//double z21 = this->GainMatrix(nextTheta, lastphi);//std::pow(10,this->GainMatrix(nextTheta, lastphi)/10);
|
|||
|
//double z22 = this->GainMatrix(nextTheta, nextPhi);//std::pow(10,this->GainMatrix(nextTheta, nextPhi)/10);
|
|||
|
double z11 = std::pow(10,this->GainMatrix(lasttheta, lastphi)/10);
|
|||
|
double z12 = std::pow(10,this->GainMatrix(lasttheta, nextPhi)/10);
|
|||
|
double z21 = std::pow(10,this->GainMatrix(nextTheta, lastphi)/10);
|
|||
|
double z22 = std::pow(10,this->GainMatrix(nextTheta, nextPhi)/10);
|
|||
|
double x = theta;
|
|||
|
double y = phi;
|
|||
|
GainValue = (z11 * (x2 - x) * (y2 - y)
|
|||
|
+ z21 * (x - x1) * (y2 - y)
|
|||
|
+ z12 * (x2 - x) * (y - y1)
|
|||
|
+ z22 * (x - x1) * (y - y1));
|
|||
|
GainValue = GainValue / ((x2 - x1) * (y2 - y1));
|
|||
|
GainValue = 10.0 * std::log10(GainValue); // <20><><EFBFBD><EFBFBD>dB
|
|||
|
//qDebug() << "GainValue:" << GainValue << " " << lasttheta << " " << nextTheta << " " << lastphi << " " << nextPhi << " " << z11 << " " << z12 << " " << z21 << " " << z22;
|
|||
|
ErrorCode::SUCCESS;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
return ErrorCode::SUCCESS;
|
|||
|
}
|
|||
|
|
|||
|
ErrorCode AbstractRadiationPattern::getGainLinear(double& theta, double& phi, double& GainValue)
|
|||
|
{
|
|||
|
ErrorCode statecode=this->getGain(theta, phi, GainValue);
|
|||
|
if (statecode == ErrorCode::OUTOFRANGE) {
|
|||
|
GainValue = 0;
|
|||
|
return ErrorCode::SUCCESS;
|
|||
|
}
|
|||
|
else {
|
|||
|
return statecode;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
ErrorCode AbstractRadiationPattern::setGain(double& theta, double& phi, double& GainValue)
|
|||
|
{
|
|||
|
this->GainMap.push_back(RadiationPatternGainPoint{ theta,phi,GainValue });
|
|||
|
return ErrorCode::SUCCESS;
|
|||
|
}
|
|||
|
|
|||
|
ErrorCode AbstractRadiationPattern::RecontructGainMatrix(double threshold )
|
|||
|
{
|
|||
|
this->thetas.clear();
|
|||
|
this->phis.clear();
|
|||
|
|
|||
|
for(long i=0;i<this->GainMap.size();i++){
|
|||
|
double thetatempp = this->GainMap[i].theta;
|
|||
|
double phitempp = this->GainMap[i].phi;
|
|||
|
InsertValueInStdVector(this->thetas, this->GainMap[i].theta, false);
|
|||
|
InsertValueInStdVector(this->phis, this->GainMap[i].phi, false);
|
|||
|
}
|
|||
|
|
|||
|
this->GainMatrix = Eigen::MatrixXd::Zero(this->phis.size(), this->thetas.size());
|
|||
|
for (long i = 0; i < this->GainMap.size(); i++) {
|
|||
|
long theta_idx = FindValueInStdVector(this->thetas, this->GainMap[i].theta);
|
|||
|
long phi_idx = FindValueInStdVector(this->phis, this->GainMap[i].phi);
|
|||
|
if (theta_idx == -1 || phi_idx == -1) {
|
|||
|
qDebug() << "Error: RecontructGainMatrix failed";
|
|||
|
return ErrorCode::FIND_ID_ERROR;
|
|||
|
}
|
|||
|
this->GainMatrix(theta_idx, phi_idx) = this->GainMap[i].GainValue;
|
|||
|
}
|
|||
|
// double mintheta, maxtheta, minphi, maxphi;
|
|||
|
this->mintheta = this->thetas[0];
|
|||
|
this->maxtheta = this->thetas[this->thetas.size() - 1];
|
|||
|
this->minphi = this->phis[0];
|
|||
|
this->maxphi = this->phis[this->phis.size() - 1];
|
|||
|
|
|||
|
this->maxGain = this->GainMatrix.maxCoeff();// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
{
|
|||
|
this->EdgethetaMin = -90;
|
|||
|
this->EdgethetaMax = 90;
|
|||
|
this->EdgeXMax = 1;
|
|||
|
this->EdgeXMin = -1;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
{
|
|||
|
double phi = 0;
|
|||
|
double theta = 0;
|
|||
|
double dt = 1e-6;
|
|||
|
double maxphiGain = 0;
|
|||
|
this->getGain(theta, phi, maxphiGain);
|
|||
|
|
|||
|
double gain_tmep = maxphiGain;
|
|||
|
while (theta <= 90) {
|
|||
|
this->getGain(theta, phi, gain_tmep);
|
|||
|
if (gain_tmep > maxphiGain) {
|
|||
|
maxphiGain = gain_tmep;
|
|||
|
}
|
|||
|
theta = theta + dt;
|
|||
|
}
|
|||
|
while (theta >=- 90) {
|
|||
|
gain_tmep = this->getGain(theta, phi);
|
|||
|
if (gain_tmep > maxphiGain) {
|
|||
|
maxphiGain = gain_tmep;
|
|||
|
}
|
|||
|
theta = theta - dt;
|
|||
|
}
|
|||
|
this->maxPhiGain = maxphiGain;
|
|||
|
qDebug() << "phi=0 Gain : \t" << maxphiGain << " -- " << theta << " -- " << phi;
|
|||
|
}
|
|||
|
|
|||
|
{
|
|||
|
double phi = 90;
|
|||
|
double theta = 0;
|
|||
|
double dt = 1;
|
|||
|
double maxphiGain = 0;
|
|||
|
this->getGain(theta, phi, maxphiGain);
|
|||
|
|
|||
|
double gain_tmep = maxphiGain;
|
|||
|
|
|||
|
while (theta <= 90) {
|
|||
|
this->getGain(theta, phi, gain_tmep);
|
|||
|
if (gain_tmep > maxphiGain) {
|
|||
|
maxphiGain = gain_tmep;
|
|||
|
}
|
|||
|
else {}
|
|||
|
|
|||
|
theta = theta + dt;
|
|||
|
}
|
|||
|
theta = 0;
|
|||
|
while (theta >= -90) {
|
|||
|
gain_tmep = this->getGain(theta, phi);
|
|||
|
if (gain_tmep > maxphiGain) {
|
|||
|
maxphiGain = gain_tmep;
|
|||
|
}
|
|||
|
theta = theta - dt;
|
|||
|
}
|
|||
|
|
|||
|
this->maxThetaGain = maxphiGain;
|
|||
|
qDebug() << "phi=90 Gain : \t" << maxphiGain << " -- " << theta << " -- " << phi;
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>㷽λ<E3B7BD><CEBB>ɨ<EFBFBD><C9A8><EFBFBD>ǵķ<C7B5>Χ<EFBFBD><CEA7>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>dBΪ<42><CEAA>λ<EFBFBD><CEBB>ѡ<EFBFBD><D1A1>phi=0 ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲻͬtheta<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>棩
|
|||
|
{
|
|||
|
double thetaEdgeMax = 0;
|
|||
|
double thetaEdgeMin = 0;
|
|||
|
double nexttheta = 0;
|
|||
|
double gain_temp = this->maxPhiGain;
|
|||
|
double phi = 0;
|
|||
|
double dt = 1e-5;
|
|||
|
double dgain = 0;
|
|||
|
// ֱ<><D6B1>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1e-6<>η<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
|||
|
while (thetaEdgeMax <= 90) {
|
|||
|
gain_temp = this->getGain(thetaEdgeMax, phi);
|
|||
|
if (gain_temp - this->maxPhiGain < threshold) {
|
|||
|
break;
|
|||
|
}
|
|||
|
thetaEdgeMax = thetaEdgeMax + dt;
|
|||
|
}
|
|||
|
|
|||
|
while (thetaEdgeMin > -90) {
|
|||
|
gain_temp = this->getGain(thetaEdgeMin, phi);
|
|||
|
if (gain_temp - this->maxPhiGain < threshold) {
|
|||
|
break;
|
|||
|
}
|
|||
|
thetaEdgeMin = thetaEdgeMin - dt;
|
|||
|
}
|
|||
|
|
|||
|
this->EdgethetaMax = thetaEdgeMax;
|
|||
|
this->EdgethetaMin = thetaEdgeMin;
|
|||
|
qDebug() << "phi=0 theta :\t" << thetaEdgeMin << " -- " << thetaEdgeMax;
|
|||
|
|
|||
|
this->EdgeXMax = std::sin(thetaEdgeMax * d2r); // <20><><EFBFBD><EFBFBD>X <20>᷶Χ
|
|||
|
this->EdgeXMin = -1*std::sin(thetaEdgeMin * d2r);
|
|||
|
}
|
|||
|
return ErrorCode::SUCCESS;
|
|||
|
}
|
|||
|
|
|||
|
std::vector<double> AbstractRadiationPattern::getThetas()
|
|||
|
{
|
|||
|
return this->thetas;
|
|||
|
}
|
|||
|
|
|||
|
std::vector<double> AbstractRadiationPattern::getPhis()
|
|||
|
{
|
|||
|
return this->phis;
|
|||
|
}
|
|||
|
|
|||
|
Eigen::MatrixXd AbstractRadiationPattern::getGainMatrix()
|
|||
|
{
|
|||
|
return this->GainMatrix;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|