ZOJ 1598 Spherical Triangle
题意:给出经纬度,求球面三角形的三角和。
看了一下午的维基百科才知道他到底说了什么,英语是真烂啊。。。 晚上A码的时候也特别慢,看来自己修炼之路还很长,最后还是在师哥的协助下A掉
公式:(其中a,b,c都是弧度,C是球面三角形的一个角)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <stdio.h> #include <math.h> const double PI=acos(-1); struct Node { double x,y,z; }node[4]; double dis(Node A,Node B) { return (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y)+(A.z-B.z)*(A.z-B.z); } int main(int argc, char *argv[]) { double a_2,b_2,c_2,x,y; int T,i; double A1,B1,C1,A2,B2,C2; scanf("%d",&T); while(T--) { for (i=0;i<3;i++) { scanf("%lf%lf",&x,&y); node[i].x=cos(x*PI/180.0)*cos(y*PI/180.0); node[i].y=cos(y*PI/180.0)*sin(x*PI/180.0); node[i].z=sin(y*PI/180.0); } a_2=dis(node[0],node[1]); b_2=dis(node[1],node[2]); c_2=dis(node[0],node[2]); A1=acos(1-a_2/2.0); B1=acos(1-b_2/2.0); C1=acos(1-c_2/2.0); A2=acos((cos(A1)-cos(B1)*cos(C1))/(sin(C1)*sin(B1))); B2=acos((cos(B1)-cos(A1)*cos(C1))/(sin(A1)*sin(C1))); C2=acos((cos(C1)-cos(A1)*cos(B1))/(sin(A1)*sin(B1))); printf("%.2lf\n",(A2+B2+C2)*180.0/PI); } return 0; }
附:
where .