如圖,給你圓上兩點的夾角,和點與圓中心的距離,
求出兩點的弧長與弦長。
--------------------------------------------------
方法:
如果夾角超過180度則用360去減夾角,
例如兩點夾角200度,也就是說兩點其實是夾角160度。
60 degree = 1 min
弧長:圓周長*(給的角度/360)。
弦長:有邊有角度,餘弦定理。
注意! PI要用2*acos(0)
--------------------------------------------------
/* 20150922
 * hanting
 * UVa 10221 - Satellites
 * C++
 */
#include <iostream>
#include <cmath>//cos,sqrt
#include <iomanip>//setprecision
using namespace std;
#define PI 2*acos(0)
int main()
{
    double s,a;
    string str;
    while(cin>>s>>a>>str)
    {
        if(a>180) a=360-a;
        double r=6440+s;
        double arc,chord;
        if(str=="min")
        {
            a/=60; //degree=min/60
        }
        arc=2*PI*r*a/360.;
        chord=sqrt(r*r+r*r-2*r*r*cos(PI*a/180.));
        cout<<fixed<<setprecision(6)<<arc<<" "<<chord<<endl;
    }
    return 0;
}
沒有留言:
張貼留言