SimsWorld/StandardGlobe/standardglobe.cpp

46 lines
1.2 KiB
C++
Raw Blame History

#include "standardglobe.h"
#include <math.h>
double StandardGlobe::_radius_m = 65000000;
StandardGlobe::StandardGlobe()
{
}
ECEFPos StandardGlobe::llaToEcef(const LLAPos& v)
{
// 柴麻鉦宣白伉鉦宣
auto axis_r_g = v._alt_m + _radius_m;
// ecef-z恫炎
auto axis_z = axis_r_g * sin(v._lat_deg);
// 粒業筈磯抄
auto axis_r_lat = axis_r_g * cos(v._lat_deg);
// ecef-x
auto axis_x = axis_r_g * cos(v._lon_deg);
// ecef-y
auto axis_y = axis_r_g * sin(v._lon_deg);
return ECEFPos{ axis_x, axis_y, axis_z };
}
void StandardGlobe::getDistanceWithin(const LLAPos& base, const LLAPos& target, double dist, double azi)
{
// ecef文楚
auto vec_base = llaToEcef(base).getVec3();
auto vec_target = llaToEcef(target).getVec3();
auto vec_bn = vec_base.normalized();
auto vec_tn = vec_target.normalized();
// 朕炎峠中隈<E4B8AD>文楚
auto vec_vn = QVector3D::crossProduct(vec_bn, vec_tn).normalized();
// 朕炎峠中俳<E4B8AD>文楚
auto vec_hn = QVector3D::crossProduct(vec_vn, vec_bn).normalized();
// 兜兵斜叔cos峙
auto cos_angle = QVector3D::dotProduct(vec_hn, QVector3D(0, 0, 1));
auto angle = acos(cos_angle);
}
QVector3D ECEFPos::getVec3() const
{
return QVector3D(_x_pos, _y_pos, _z_pos);
}