大意
给出圆的半径 和 圆心角(夹角) ,求出圆心角所对应的圆弧距离和直线弦距离。
思路
假设 为圆的半径,圆心角的角度 (以度为单位),。
以度为单位:
-
圆弧距离:
-
直线弦距离:
以分为单位:
-
圆弧距离:
-
直线弦距离:
代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double r = 6440; //地球半径
int main() {
double s, a;//s:卫星与地球表面的距离,a:两颗卫星对地球中心的夹角
string str;
while (cin >> s >> a >> str) {
if (str[0] == 'm') {
a /= 60;//分转换为度
}
double angle = M_PI * a / 180;
double arc = angle * (s + r);//圆弧距离
double dis = 2 * (s + r) * sin(angle / 2);//直线弦距离
if (a > 180) {//夹角大于180度
arc = 2 * M_PI * (s + r) - arc;
}
cout << fixed << setprecision(6) << arc;
cout << " ";
cout << fixed << setprecision(6) << dis;
cout << "\n";
}
return 0;
}