SimsWorld/StandardGlobe/standardglobe.h

109 lines
2.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "standardglobe_global.h"
#define PI 3.14159265358979323846
#define deg2a(v) v / 180.0 * PI
#define rad2d(v) v / PI * 180.0
class QVector3D;
/// <summary>
/// 经纬度坐标
/// </summary>
struct LonLatPos {
double _lon_deg = 0;
double _lat_deg = 0;
};
/// <summary>
/// 经纬高坐标系坐标
/// </summary>
struct STANDARDGLOBE_EXPORT LonLatAlt {
double _lon_deg = 0;
double _lat_deg = 0;
double _alt_m = 0;
LonLatAlt(double lon = 0, double lat = 0, double alt = 0);
LonLatAlt(const LonLatPos& plain_pos);
LonLatPos toLonLatPos() const;
};
/// <summary>
/// 地心坐标系
/// </summary>
struct ECEFv3d {
double _x_pos = 0;// 指向0°经度圈与纬度0°交点
double _y_pos = 0;
double _z_pos = 0;
QVector3D getVec3() const;
static ECEFv3d fromVec3(const QVector3D& p);
};
/// <summary>
/// 东天北坐标系
/// </summary>
struct ENUv3d {
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 ECEFv3d llaToEcef(const LonLatAlt& v);
static LonLatAlt ecefToLLA(const ECEFv3d& v);
/// <summary>
/// 根据LLA坐标获取两点之间的大地线长度和b->t初始方位角warning本计算忽视LLA的高度值
/// </summary>
/// <param name="base"></param>
/// <param name="target"></param>
/// <param name="dist"></param>
/// <param name="azi"></param>
static void getDistanceWithLLA(const LonLatAlt& base, const LonLatAlt& target, double& dist, double& azi);
/// <summary>
/// 根据两点之间的大地线长度和b->t初始方位角计算目标LLA定位坐标
/// </summary>
/// <param name="base"></param>
/// <param name="dist"></param>
/// <param name="azi"></param>
/// <param name="target"></param>
static void getLLAWithDistance(const LonLatAlt& base, double dist, double azi, LonLatAlt& target);
/// <summary>
/// 通过LLA坐标获取目标极坐标
/// </summary>
/// <param name="base"></param>
/// <param name="target"></param>
/// <returns></returns>
static PolarPos getPolarWithLLA(const LonLatAlt& base, const LonLatAlt& target);
/// <summary>
/// 通过极坐标获取目标LLA坐标
/// </summary>
/// <param name="base"></param>
/// <param name="target"></param>
/// <returns></returns>
static LonLatAlt getLLAWithPolar(const LonLatAlt& base, const PolarPos& target);
};