zoukankan      html  css  js  c++  java
  • ZOJ 3598 Spherical Triangle球面几何公式应用

    #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
    ",ans * 180.0 / PI);
        }
        return 0;
    }
  • 相关阅读:
    docker 入门(docker 镜像 、容器、仓库)
    windows 安装 docker
    关于go mod 的使用和goland 配置 go mod
    mac 安装docker
    vm 将宿主机文件夹 映射至 虚拟机
    centos 关于yum无法使用
    mac 安装 swoole 可能会出现的错误
    BZOJ3378:[USACO]MooFest 狂欢节(树状数组)
    BZOJ3110:[ZJOI2013]K大数查询(整体二分)
    BZOJ4170:极光(CDQ分治)
  • 原文地址:https://www.cnblogs.com/Commence/p/4535271.html
Copyright © 2011-2022 走看看