From 73dc83d8f3c143f2b396ed04cb16fccabd4f7382 Mon Sep 17 00:00:00 2001
From: codeboss <2422523675@qq.com>
Date: Sat, 7 Jun 2025 16:44:25 +0800
Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=B7=A5=E7=A8=8B=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81=E5=88=86=E5=B8=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ComponentBasic/ComponentBasic.vcxproj | 4 +-
MessageBasic/MessageBasic.vcxproj | 2 +-
MessageBasic/messagebasic.h | 4 +-
StandardGlobe/StandardGlobe.vcxproj | 2 +-
StandardGlobe/standardglobe.cpp | 64 +++++++++++++++++++++++++++
StandardGlobe/standardglobe.h | 21 +++++++--
6 files changed, 88 insertions(+), 9 deletions(-)
diff --git a/ComponentBasic/ComponentBasic.vcxproj b/ComponentBasic/ComponentBasic.vcxproj
index 579a290..86ba03e 100644
--- a/ComponentBasic/ComponentBasic.vcxproj
+++ b/ComponentBasic/ComponentBasic.vcxproj
@@ -37,7 +37,7 @@
5.12.11_msvc2017_64
- core
+ core;gui
debug
@@ -60,7 +60,7 @@
- $(SolutionDir)SimsBasic;$(SolutionDir)MessageBasic;$(IncludePath)
+ $(SolutionDir)SimsBasic;$(SolutionDir)MessageBasic;$(SolutionDir)StandardGlobe;$(IncludePath)
$(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath)
diff --git a/MessageBasic/MessageBasic.vcxproj b/MessageBasic/MessageBasic.vcxproj
index 1e52966..c3ba860 100644
--- a/MessageBasic/MessageBasic.vcxproj
+++ b/MessageBasic/MessageBasic.vcxproj
@@ -37,7 +37,7 @@
5.12.11_msvc2017_64
- core
+ core;gui
debug
diff --git a/MessageBasic/messagebasic.h b/MessageBasic/messagebasic.h
index 05bb00a..e9b09ec 100644
--- a/MessageBasic/messagebasic.h
+++ b/MessageBasic/messagebasic.h
@@ -1,8 +1,8 @@
#pragma once
#include "messagebasic_global.h"
-#include "simsbasic.h"
-#include "standardglobe.h"
+#include
+#include
#define NAME(v) #v
#define DOUBLE_SAVE(u) obj[NAME(u)] = u
diff --git a/StandardGlobe/StandardGlobe.vcxproj b/StandardGlobe/StandardGlobe.vcxproj
index e98440f..a91c0de 100644
--- a/StandardGlobe/StandardGlobe.vcxproj
+++ b/StandardGlobe/StandardGlobe.vcxproj
@@ -37,7 +37,7 @@
5.12.11_msvc2017_64
- core;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender
+ core;gui
debug
diff --git a/StandardGlobe/standardglobe.cpp b/StandardGlobe/standardglobe.cpp
index 6ff891b..7d1438d 100644
--- a/StandardGlobe/standardglobe.cpp
+++ b/StandardGlobe/standardglobe.cpp
@@ -1,5 +1,6 @@
#include "standardglobe.h"
#include
+#include
double StandardGlobe::_radius_m = 65000000;
#define PI 3.14159265354
@@ -95,7 +96,70 @@ void StandardGlobe::getTargetLLAWithDistance(const LLAPos& base, double dist, do
target = ecefToLLA(sv);
}
+PolarPos StandardGlobe::getPolarWithLLA(const LLAPos& base, const LLAPos& target)
+{
+ // 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));
+ auto angle = acos(cos_angle);
+
+ // 180°校验
+ auto flag_vec = QVector3D::crossProduct(vec_hn, QVector3D(0, 0, 1)).normalized();
+ if (vec_bn.z() * flag_vec.z() < 0)
+ angle = 2 * PI - angle;
+
+ // 返回方位角
+ auto azi_deg = rad2d(angle);
+
+ // 视线矢量
+ auto vec_bt = vec_target - vec_base;
+ auto vec_btn = vec_bt.normalized();
+ auto cos_pitch = QVector3D::dotProduct(vec_hn, vec_btn);
+ auto pit_deg = rad2d(acos(cos_pitch));
+
+ PolarPos p;
+ p._azimuth_deg = azi_deg;
+ p._pitch_deg = pit_deg;
+ p._dist_m = vec_bt.length();
+ return p;
+}
+
+LLAPos StandardGlobe::getLLAWithPolar(const LLAPos& base, const PolarPos& target)
+{
+ auto ecef_b = llaToEcef(base).getVec3();
+ auto u_azi = QQuaternion(-deg2a(target._azimuth_deg), ecef_b.normalized());
+
+ auto vec_ts = u_azi.rotatedVector(QVector3D(0,0,1)).normalized();
+ auto axis_pitch = QVector3D::crossProduct(vec_ts, ecef_b.normalized());
+ auto u_pit = QQuaternion(deg2a(target._pitch_deg), axis_pitch);
+
+ auto r_shadow = target._dist_m * cos(deg2a(target._pitch_deg));
+ auto ts_appv = u_pit.rotatedVector(vec_ts).normalized() * r_shadow;
+
+ auto ecef_target = ecef_b + ts_appv;
+ ECEFPos tt = ECEFPos::fromVec3(ecef_target);
+
+ return ecefToLLA(tt);
+}
+
QVector3D ECEFPos::getVec3() const
{
return QVector3D(_x_pos, _y_pos, _z_pos);
}
+ECEFPos ECEFPos::fromVec3(const QVector3D& p) {
+ ECEFPos o;
+ o._x_pos = p.x();
+ o._y_pos = p.y();
+ o._z_pos = p.z();
+ return o;
+}
diff --git a/StandardGlobe/standardglobe.h b/StandardGlobe/standardglobe.h
index a08ede2..91074ab 100644
--- a/StandardGlobe/standardglobe.h
+++ b/StandardGlobe/standardglobe.h
@@ -1,7 +1,8 @@
#pragma once
#include "standardglobe_global.h"
-#include
+
+class QVector3D;
///
/// 经纬高坐标系坐标
@@ -16,10 +17,11 @@ struct LLAPos {
/// 地心坐标系
///
struct ECEFPos {
- double _x_pos = 0;
+ double _x_pos = 0;// 指向0°经度圈与纬度0°交点
double _y_pos = 0;
double _z_pos = 0;
QVector3D getVec3() const;
+ static ECEFPos fromVec3(const QVector3D& p);
};
///
@@ -72,5 +74,18 @@ public:
///
///
static void getTargetLLAWithDistance(const LLAPos& base, double dist, double azi, LLAPos& target);
-
+ ///
+ /// 通过LLA坐标,获取目标极坐标
+ ///
+ ///
+ ///
+ ///
+ static PolarPos getPolarWithLLA(const LLAPos &base, const LLAPos &target);
+ ///
+ /// 通过极坐标,获取目标LLA坐标
+ ///
+ ///
+ ///
+ ///
+ static LLAPos getLLAWithPolar(const LLAPos &base, const PolarPos &target);
};