# UVA 10221 Satellites
## 題目連結 [UVA 10221](https://vjudge.net/problem/UVA-10221)
### 題目內容
The radius of earth is 6440 Kilometer. There are many Satellites and Asteroids moving around the earth. If two Satellites create an angle with the center of earth, can you find out the distance between them? By distance we mean both the arc and chord distances. Both satellites are on the same orbit (However, please consider that they are revolving on a circular path rather than an elliptical path).
### 輸入限制
The input file will contain one or more test cases. Each test case consists of one line containing two-integer s and a, and a string ‘min’ or ‘deg’. Here s is the distance of
the satellite from the surface of the earth and a is the angle that the satellites make with the center of earth. It may be in minutes (′ ) or in degrees (◦ ). Remember that the same line will never contain minute and degree at a time.
### 輸出限制
For each test case, print one line containing the required distances i.e. both arc distance and chord distance respectively between two satellites in Kilometer. The distance will be a floating-point value with six digits after decimal point.
### 解題思路
1.這題要計算圓弧距離和直線弦距離
2.min為角分、deg為角度,1角度為60角分
3.圓弧距離公式為2* pi * radius *(角度/360度)
4.直線弦距離公式為2 * (radius * (sin(角度/2 * pi /180度)))
5.需要注意radius還需要加上地球的半徑6440.0,c++的sin內必須放弧度而不是角度,弧度的算法為角度 * pi/180、若角度超過180.0需要用360.0扣掉
### 程式碼
```cpp=
#include<bits/stdc++.h>
using namespace std;
#define PI asin(1)*2.0
int main(){
double s,a,ans1,ans2;
string angle;
while(cin>>s>>a>>angle){
s+=6440.0;
ans1=0;
ans2=0;
if(angle=="min"){
a/=60.0;
}
if(a>180.0){
a=360.0-a;
}
ans1=abs(s*2.0*PI*(a/360.0));
ans2=abs(2.0*(s*(sin(a/2.0*PI/180.0))));
printf("%.6f %.6f\n",ans1,ans2);
}
}
```
## 測資
### Sample input
500 30 deg
700 60 min
200 45 deg
### Sample output
3633.775503 3592.408346
124.616509 124.614927
5215.043805 5082.035982