#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; }
时间: 2024-10-13 07:29:09