-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransformation.cpp
More file actions
175 lines (147 loc) · 6.97 KB
/
Transformation.cpp
File metadata and controls
175 lines (147 loc) · 6.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*************************************************************************************
*文件名称:坐标转换 *
*作 者: *
*版 本: *
*日 期: *
*功能描述:本程序为坐标转换模型,用于经纬度与球坐标之间的相互转换。 *
*输 入:该程序为多输入,输入为经纬度或者球坐标系中的仰角和方位角。 *
*输 出:该程序为多输出,输出为球坐标系中的仰角和方位角或者经纬度。 *
*函数列表:1.getDeg()——用于弧度制转换为角度制; *
* 2.getRad()——用于角度制转换为弧度制; *
* 3.getAzimuth()——用于通过经度来计算方位角; *
* 4.getElevation()——用于通过纬度来计算仰角; *
* 5.getLng()——用于通过方位角来计算经度; *
* 6.getLat()——用于通过仰角来计算纬度; *
* 7.getX()——用于通过球坐标来计算直角坐标系中的x坐标; *
* 8.getY()——用于通过球坐标来计算直角坐标系中的y坐标; *
* 9.getZ()——用于通过球坐标来计算直角坐标系中的z坐标; *
* 10.getR()——用于通过直角坐标来计算球坐标系中的距离; *
* 11.getEL()——用于通过直角坐标来计算球坐标系中的仰角; *
* 12.getAZ()——用于通过直角坐标来计算球坐标系中的方位角。 *
*历 史: *
* Copyright (c) wangchong. All Rights Reserved *
*************************************************************************************/
#include "Transformation.h"
#include <cmath>
Transformation::Transformation()
{
}
Transformation::~Transformation()
{
}
/*************************************************************************************
* 描述:getDeg()函数用于计算角度,输入为弧度制Rad,输出为角度制Deg。 *
*************************************************************************************/
double Transformation::getDeg(double Rad)
{
double pi = atan(1) * 4;
double Deg = Rad * 180 / pi;
return Deg;
}
/*************************************************************************************
* 描述:getRad()函数用于计算弧度,输入为角度Deg,输出为弧度Rad。 *
*************************************************************************************/
double Transformation::getRad(double Deg)
{
double pi = atan(1) * 4;
double Rad = Deg * pi / 180;
return Rad;
}
/*************************************************************************************
*描述:getAzimuthe()函数用于计算球坐标系中的方位角,输入为经度Lng,输出为方位角AZ。 *
*************************************************************************************/
double Transformation::getAzimuth(double Lng) //计算球坐标系中的方位角
{
double AZ = Lng;
return AZ;
}
/*************************************************************************************
*描述:getElevation()函数用于计算球坐标系中的仰角,输入为纬度Lat,输出为仰角EL。 *
*************************************************************************************/
double Transformation::getElevation(double Lat) //计算球坐标系中的仰角
{
double EL = 90 - Lat;
return EL;
}
/*************************************************************************************
*描述:getLng()函数用于计算经度,输入为球坐标系中的方位角AZ,输出为经度Lng。 *
*************************************************************************************/
double Transformation::getLng(double AZ) //计算经度
{
double Lng = AZ;
return Lng;
}
/*************************************************************************************
*描述:getLat()函数用于计算纬度,输入为球坐标系中的仰角EL,输出为纬度Lat。 *
*************************************************************************************/
double Transformation::getLat(double EL) //计算纬度
{
double Lat = 90 - EL;
return Lat;
}
/*************************************************************************************
* 描述:getX()函数用于计算x坐标,输入为球坐标系中的距离R,仰角EL,方位角AZ,输出为x坐*
* 标。 *
*************************************************************************************/
double Transformation::getX(double R, double EL, double AZ)
{
double X = R * sin(EL) * cos(AZ);
return X;
}
/*************************************************************************************
* 描述:getY()函数用于计算y坐标,输入为球坐标系中的距离R,仰角EL,方位角AZ,输出为y坐*
* 标。 *
*************************************************************************************/
double Transformation::getY(double R, double EL, double AZ)
{
double Y = R * sin(EL) * sin(AZ);
return Y;
}
/*************************************************************************************
* 描述:getZ()函数用于计算z坐标,输入为球坐标系中的距离R,仰角EL,输出为z坐标。 *
*************************************************************************************/
double Transformation::getZ(double R, double EL)
{
double Z = R * cos(EL);
return Z;
}
/*************************************************************************************
* 描述:getR()函数用于计算球坐标系中的距离参数,输入为空间直角坐标系中的x、y、z坐标,*
* 输出为球坐标系中的距离R。 *
*************************************************************************************/
double Transformation::getR(double x, double y, double z)
{
double R = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
return R;
}
/*************************************************************************************
* 描述:getEL()函数用于计算球坐标系中的仰角,输入为空间直角坐标系中的x、y、z坐标,输 *
* 出为球坐标系中的仰角EL。 *
*************************************************************************************/
double Transformation::getEL(double x, double y, double z)
{
double R = getR(x, y, z);
double EL = acos(z / R);
return EL;
}
/*************************************************************************************
* 描述:getAZ()函数用于计算球坐标系中的方位角 ,输入为空间直角坐标系中的x、y、z坐标,*
* 输出为球坐标系中的方位角AZ。 *
*************************************************************************************/
double Transformation::getAZ(double x, double y)
{
double AZ = atan(y / x);
double pi = atan(1) * 4;
if (x < 0)
{
if (AZ < 0)
{
AZ = AZ + pi;
}
else
{
AZ = AZ - pi;
}
}
return AZ;
}