ZOJ 3598 Spherical Triangle球面几何公式应用
2015-05-28 10:34
399 查看
#include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio> #include <string> #include <vector> #include <climits> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> #define LL long long #define PI 3.1415926535897932626 using namespace std; int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} const double eps = 1e-8; //有这么个公式cosa=cosb*cosc+sinb*sinc*cosA //其中小写a,b,c表示球面三角形边长所对应的圆心角 大写A表示三角形内角 struct node { double x,y; }; //计算圆心角lat表示纬度,lng表示经度,-90 <= w <= 90; //计算两点所在大圆劣弧对应圆心角,0 <= angle <= pi; double angle(double lng1,double lat1,double lng2,double lat2) { double dlng = fabs(lng1 - lng2) * PI / 180; while(dlng + eps > PI + PI) dlng -= PI + PI; if (dlng > PI) dlng = 2 * PI - dlng; lat1 *= PI / 180; lat2 *= PI / 180; return acos(cos(lat1) * cos(lat2) * cos(dlng) + sin(lat1) * sin(lat2)); } double get_A(double a,double b,double c) { return acos((cos(a) - cos(b) * cos(c)) / (sin(b) * sin(c))); } int main() { int T; scanf("%d",&T); while (T--) { node a,b,c; scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y); double ta = angle(a.x,a.y,b.x,b.y); double tb = angle(b.x,b.y,c.x,c.y); double tc = angle(a.x,a.y,c.x,c.y); double ans = 0; ans += get_A(ta,tb,tc); ans += get_A(tb,tc,ta); ans += get_A(tc,ta,tb); printf("%.2lf\n",ans * 180.0 / PI); } return 0; }
相关文章推荐
- zoj 3598 Spherical Triangle 一道很纯的公式题,经纬线计算球面内角和
- HDU 4870 Rating(概率、期望、推公式) && ZOJ 3415 Zhou Yu
- 泊松分布的来源—公式推导—应用
- (队列的应用5.3.1)ZOJ 3210 A Stack or A Queue?根据进入结构的序列和离开结构的序列确定是stack还是queue)
- ZOJ 1889 题解利用公式很快就解出来了
- 公式解析 在某些应用中,为了支持灵活性,往往用到自定义的公式。 比如,有如下的原始公式集合:
- Excel在统计分析中的应用—第九章—非参数检验-独立性检验(x2统计量简化公式应用)
- 拆分公式函数及应用
- 〔转〕Word域的应用和详解2_等式和公式域
- Zoj 1655 Transport Goods 最短路的应用
- 凌台公式的应用fzu1010
- Excel手工公式、SUM函数、IF函数在评价量规中的应用
- 求和公式的应用
- 博客园中应用LaTex进行公式编写
- zoj 3209(Dancing Links应用)
- ZOJ 3981 Balloon Robot CCPC2017 Qinhuangdao(推公式+离线处理)
- 高等数学:第八章 多元函数微分法及其应用(2)多元复合函数求导法 隐函数的求导公式 微分法在几何上的应用
- Simpson公式的应用(HDU 1724/ HDU 1071)
- Excel数据透视表应用之二表内建公式
- poj--1061青蛙的约会(扩展欧几里得公式的应用)