题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4682

As everybody knows, the sum of the interior angles of a triangle on a plane is always 180 degree. But this is not true when the triangle is on spherical surface. Given a triangle on a spherical surface, you are asked to calculate the sum of the interior angles of the triangle.

Formally, you are given the 3 vertex of the triangle. They are connected by the arcs of the great circles, i.e. circles whose centers coincide with the center of the sphere. It is guaranteed that the triangle is not degenerate, i.e. the 3 vertices will not lie on one great circle and no two vertices collide. The interior of the triangle is defined as the smaller part that the triangle is divide into.

Input

There are multiple test cases. The first line of input contains an integer T (0 < T ≤ 2012) indicating the number of test cases. Then T test cases follow.

Each test case contains 3 lines, indicating the position of the 3 vertices. Each line contains 2 real number, each of which contains at most 2 digits after the decimal point, indicating the longitude and the latitude of the vertex. The longitude and the latitude are measured in degree. The longitude will be in (-180, 180] while the latitude will be in [-90, 90].

Output

For each test case, output the sum of the interior angles of the triangle measured in degree, accurate to 0.01.

Sample Input

1
0 0
90 0
0 90

Sample Output

270.00

References

  • http://en.wikipedia.org/wiki/Spherical_trigonometry

百度百科:球面三角

代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <malloc.h>
#include <ctype.h>
#include <math.h>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <set>
#include <map>
#define pi acos(-1.0)
double line_dist(double r,double lng1,double lat1,double lng2,double lat2)
{double dlng=fabs(lng1-lng2)*pi/180;while (dlng>=pi+pi)dlng-=pi+pi;if (dlng>pi)dlng=pi+pi-dlng;lat1*=pi/180,lat2*=pi/180;return r*sqrt(2-2*(cos(lat1)*cos(lat2)*cos(dlng)+sin(lat1)*sin(lat2)));
}double angle(double lng1,double lat1,double lng2,double lat2)
{double dlng=fabs(lng1-lng2)*pi/180;while (dlng>=pi+pi)dlng-=pi+pi;if (dlng>pi)dlng=pi+pi-dlng;lat1*=pi/180,lat2*=pi/180;return acos(cos(lat1)*cos(lat2)*cos(dlng)+sin(lat1)*sin(lat2));
}inline double sphere_dist(double r,double lng1,double lat1,double lng2,double lat2)
{return r*angle(lng1,lat1,lng2,lat2);
}
double lng[5],lat[5],len[5];int main()
{int t;cin>>t;double r=1;while(t--){for(int i=0; i<3; i++){cin>>lng[i]>>lat[i];}for(int i=0; i<3; i++){len[i]=sphere_dist(r,lng[i],lat[i],lng[(i+1)%3],lat[(i+1)%3]);}double p=0;for(int i=0; i<3; i++)p+=len[i];p/=2.0;//cout<<'p'<<p<<endl;double m=sqrt((sin(p-len[0])*sin(p-len[1])*sin(p-len[2]))/sin(p));//cout<<m<<endl;double ctg[5];double sum=0;for(int i=0; i<3; i++){ctg[i]=sin(p-len[i])/m;ctg[i]=1.0/ctg[i];ctg[i]=atan(ctg[i])*2.0;sum+=ctg[i];}printf("%.2lf\n",sum/pi*180);}return 0;
}

ZOJ 3598 Spherical Triangle(计算几何 球面三角形内角和)相关推荐

  1. Zoj 3598 Spherical Triangle 【计算几何】【曲面三角形】

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3598 题目大意:给出一个球体上的三点,三点的坐标以经纬度的形式给 ...

  2. ZOJ 1598 Spherical Triangle

    题意:给出经纬度,求球面三角形的三角和. 看了一下午的维基百科才知道他到底说了什么,英语是真烂啊... 晚上A码的时候也特别慢,看来自己修炼之路还很长,最后还是在师哥的协助下A掉 公式:(其中a,b, ...

  3. 非欧几何三角形内角和大于或者小于180°

    1.欧几里得几何三角形的内角和都等于180度,非欧几何三角形内角和不等于180度. 如在球面上,在椭圆面或双曲面上,三角形的内角和小于180度. 2.在欧几里德几何学里,就是中学学习的平面几何里,三角 ...

  4. POJ 1673 EXOCENTER OF A TRIANGLE(证明+求三角形垂心)

    POJ 1673 EXOCENTER OF A TRIANGLE(证明+求三角形垂心) http://poj.org/problem?id=1673 题意: ZOJ 1821 有一个三角形ABC,扩展 ...

  5. 如何用课件制作工具验证三角形内角和

    三角形是一个基本几何图形,在初中阶段就会详细学习它的性质,并且会接触到各种形状的三角形,但不管三角形的形状怎么变,它的内角和始终是180°.为了给学生们验证这一定理的正确性,可以制作动态课件来进行演示 ...

  6. 上面两点下面一个三角形_章勤琼:三角形内角和180该如何说明 ——小学数学中的合情推理和演绎推理...

    (以下内容全文转自<教学月刊(小学版)>2019年第11期58-61页"数说九章"专栏.参考文献方式:章勤琼, 杜娅茹.三角形内角和180°该如何说明--小学数学的合情 ...

  7. 定义一个Triangle类表示三角形,测试这个三角形类的所有方法

    定义一个Triangle类表示三角形,其中三个double型变量a.b.c表示三条边长.为该类定义两个构造方法:默认构造方法设置三角形的三条边长都为0.0; 带三个参数的构造方法通过传递三个参数创建三 ...

  8. 空间三角形_教师招聘试讲-小学数学 三角形内角和 教案

    一.教学目标 [知识与能力]探究并掌握三角形内角和是180°,并能应用三角形内角和解决一些简单的实际问题. [过程与方法]学生在探索过程中,发现和提出问题,通过用转化的思想,培养学生的空间观念,几何直 ...

  9. 陈省身:三角形内角和不等于180°

    三角形 外角和为360° 作为公认的劳模,平日里,超模君不但要码字,工作之余还要监督表妹做作业,也难怪表妹成绩总是能名列前茅. 今天表妹做作业时,遇到一道判断题:"三角形的内角和等于180° ...

最新文章

  1. Stack Overflow被收购了,以后要付费“抄代码”?
  2. RecyclerView + SnapHelper实现炫酷ViewPager效果
  3. jsonp请求url长度过长的替代(ajaxcdr的使用)
  4. c++面向对象高级编程 学习七 转换函数
  5. Uniapp组件之间传参
  6. 不同网段通过静态路由实现互通,华为S5700交换机开启telnet远程指定IP登陆配置(强烈推荐)
  7. CDH5.16.2下载安装
  8. python 路由转发_[转载]无线传感器网络路由协议(转)
  9. SAP License:MR22借贷物料一步设置可以把差异带走
  10. PCL RANSAC点云配准
  11. mysql中YEARWEEK跨年引发的线上问题
  12. 对测试开发工程师的理解
  13. ubuntu22.04设置静态ip地址
  14. Leetcode 第 201 场周赛 (2020 滴滴校招专场)
  15. 车载快充 自动升降压PD快充方案
  16. 硬盘坏了可以修复吗?硬盘数据恢复方法来了
  17. 音频格式的汇总及压缩比较
  18. 短信ui--短信设置界面之sim卡短信管理
  19. 线程池详解:线程池的七大参数及运行流程
  20. 1、第一课---小玉买玩具

热门文章

  1. 1080P、720P、4CIF、CIF所需要的理论带宽
  2. mysql和oracle的使用感受 -- 差异
  3. 计算机如何安装cpu风扇,cpu风扇安装,小编教你cpu风扇怎么安装
  4. 数据库、数据库管理系统和数据库系统简述
  5. 游戏服务器Mina框架开发
  6. Ubuntu20.04或18.04下PX4(pixhawk)源码编译环境配置教程,及构建代码各种错误解决办法
  7. 睿备份支持linux,【睿备份怎么用】睿备份好不好_使用技巧-ZOL软件百科
  8. 「史上最全的 TCG 规范解读」TCG 工作组规范预览
  9. STM32F407基础总结系列(一)
  10. Win11 2022更新向所有符合兼容要求的用户开放,你会升级吗?