This commit is contained in:
codeboss 2025-06-01 22:37:26 +08:00
parent d3595566b1
commit 0397dda453
3 changed files with 81 additions and 4 deletions

View File

@ -37,7 +37,7 @@
</ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
<QtInstall>5.12.11_msvc2017_64</QtInstall>
<QtModules>core</QtModules>
<QtModules>core;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender</QtModules>
<QtBuildConfig>debug</QtBuildConfig>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">

View File

@ -1,5 +1,44 @@
#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));
}
QVector3D ECEFPos::getVec3() const
{
return QVector3D(_x_pos, _y_pos, _z_pos);
}

View File

@ -1,10 +1,10 @@
#pragma once
#include "standardglobe_global.h"
#include <qvector3d.h>
/// <summary>
/// WGS84坐标系坐标类型
/// 经纬高坐标系坐标
/// </summary>
struct LLAPos {
double _lon_deg = 0;
@ -12,11 +12,49 @@ struct LLAPos {
double _alt_m = 0;
};
/// <summary>
/// 地心坐标系
/// </summary>
struct ECEFPos {
double _x_pos = 0;
double _y_pos = 0;
double _z_pos = 0;
QVector3D getVector() const;
};
/// <summary>
/// 东天北坐标系
/// </summary>
struct ENUPos {
double _e_pos = 0;
double _n_pos = 0;
double _t_pos = 0;
};
/// <summary>
/// 极坐标
/// </summary>
struct PolarPos {
double _dist_m = 0;
double _azimuth_deg = 0;
double _pitch_deg = 0;
};
/// <summary>
/// 깃硫헷竟麟깃瘻뻣묏야
/// </summary>
class STANDARDGLOBE_EXPORT StandardGlobe
{
private:
/// <summary>
/// 标准正球体星球直径
/// </summary>
static double _radius_m;
public:
StandardGlobe();
static ECEFPos llaToEcef(const LLAPos &v);
static void getDistanceWithin(const LLAPos &base, const LLAPos &target, double dist, double azi);
};