include iostream include math using namespace std class PointSphere pr

 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
#include <iostream>
#include <math.h>
using namespace std;
class PointSphere{
private:
double lat1, lon1, rad, lat2, lon2, x, y, z;
public:
void SetDesc(){
double dx, dy, dz;
cout<<"Input x, y and z"<<endl; cin>>dx>>dy>>dz;
x = dx;
y = dy;
z = dz;
}
void SetPolar(){
double plat, plon, prad;
cout<<"Input latitude, longitude and radius"<<endl; cin>>plat>>plon>>prad;
lat1 = plat;
lon1 = plon;
rad = prad;
}
void SetPolarForLenth(){
double plat1, plon1, plat2, plon2, prad;
cout<<"Input first latitude, longitude and overall radius"<<endl; cin>>plat1>>plon1>>prad;
lat1 = plat1;
lon1 = plon1;
rad = prad;
cout<<"Input second latitude and longitude"<<endl; cin>>plat2>>plon2;
lat2 = plat2;
lon2 = plon2;
}
void ConvertToPolar(){
lat1 = atan(pow((pow(x,2) + pow(y,2)),0.5)/z);
lon1 = atan(x/y);
rad = sqrt(pow(x,2) + pow(y,2) + pow(z,2));
cout<<lat1<<"; "<<lon1<<"; "<<rad<<"; "<<endl;
}
void ConvertToDescartes(){
x = rad*cos(lat1)*cos(lon1);
y = rad*cos(lat1)*sin(lon1);
z = rad*sin(lat1);
cout<<x<<"; "<<y<<"; "<<z<<"; "<<endl;
}
void CountOfLenght(){
double AngleLenth = acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon2-lon1));
double Lenth = (rad*AngleLenth);
cout<< Lenth<<endl;
}
};
int main() {
int change = 0;
while(change<4){
cout<<"Change what you want:"<<endl;
cout<<"1 make from polar to descards"<<endl;
cout<<"2 make from descards to polar"<<endl;
cout<<"3 count of legth on sphere"<<endl;
cout<<"4 exit"<<endl;
cin>>change;
if(change == 1){
PointSphere descart;
descart.SetDesc();
descart.ConvertToPolar();
}
if(change == 2){
PointSphere polar;
polar.SetPolar();
polar.ConvertToDescartes();
}
if(change == 3){
PointSphere point;
point.SetPolarForLenth();
point.CountOfLenght();
}
}
return 0;
}