From 0397dda453b28f03d38236763692ebc6c0fa99c9 Mon Sep 17 00:00:00 2001 From: codeboss <2422523675@qq.com> Date: Sun, 1 Jun 2025 22:37:26 +0800 Subject: [PATCH] update --- StandardGlobe/StandardGlobe.vcxproj | 2 +- StandardGlobe/standardglobe.cpp | 39 +++++++++++++++++++++++++ StandardGlobe/standardglobe.h | 44 +++++++++++++++++++++++++++-- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/StandardGlobe/StandardGlobe.vcxproj b/StandardGlobe/StandardGlobe.vcxproj index 11a6985..e98440f 100644 --- a/StandardGlobe/StandardGlobe.vcxproj +++ b/StandardGlobe/StandardGlobe.vcxproj @@ -37,7 +37,7 @@ 5.12.11_msvc2017_64 - core + core;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender debug diff --git a/StandardGlobe/standardglobe.cpp b/StandardGlobe/standardglobe.cpp index 0c2a982..08b7453 100644 --- a/StandardGlobe/standardglobe.cpp +++ b/StandardGlobe/standardglobe.cpp @@ -1,5 +1,44 @@ #include "standardglobe.h" +#include +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(); + + // 目标平面法线矢量 + auto vec_vn = QVector3D::crossProduct(vec_bn, vec_tn).normalized(); + // 目标平面切线矢量 + 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); +} diff --git a/StandardGlobe/standardglobe.h b/StandardGlobe/standardglobe.h index b367ada..2ca6182 100644 --- a/StandardGlobe/standardglobe.h +++ b/StandardGlobe/standardglobe.h @@ -1,10 +1,10 @@ #pragma once #include "standardglobe_global.h" - +#include /// -/// WGS84坐标系坐标类型 +/// 经纬高坐标系坐标 /// struct LLAPos { double _lon_deg = 0; @@ -12,11 +12,49 @@ struct LLAPos { double _alt_m = 0; }; +/// +/// 地心坐标系 +/// +struct ECEFPos { + double _x_pos = 0; + double _y_pos = 0; + double _z_pos = 0; + QVector3D getVector() const; +}; + +/// +/// 东天北坐标系 +/// +struct ENUPos { + double _e_pos = 0; + double _n_pos = 0; + double _t_pos = 0; +}; + +/// +/// 极坐标 +/// +struct PolarPos { + double _dist_m = 0; + double _azimuth_deg = 0; + double _pitch_deg = 0; +}; + /// /// 标准球体坐标转换工具 /// class STANDARDGLOBE_EXPORT StandardGlobe { +private: + /// + /// 标准正球体星球直径 + /// + static double _radius_m; + public: - StandardGlobe(); + StandardGlobe(); + + static ECEFPos llaToEcef(const LLAPos &v); + static void getDistanceWithin(const LLAPos &base, const LLAPos &target, double dist, double azi); + };