UVA 11178 Morley's Theorem 计算几何模板
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> using namespace std; const double eps=1e-8; int dcmp(double x)
{
if(fabs(x)<eps) return 0; else return (x<0)?-1:1;
} struct Point
{
double x,y;
Point(double _x=0,double _y=0):x(_x),y(_y){}
}; Point operator+(Point A,Point B) {return Point(A.x+B.x,A.y+B.y);}
Point operator-(Point A,Point B) {return Point(A.x-B.x,A.y-B.y);}
Point operator*(Point A,double p) {return Point(A.x*p,A.y*p);}
Point operator/(Point A,double p) {return Point(A.x/p,A.y/p);} Point A,B,C; double Dot(Point A,Point B) {return A.x*B.x+A.y*B.y;}
double Length(Point A) {return sqrt(Dot(A,A));}
double Angle(Point A,Point B) {return acos(Dot(A,B)/Length(A)/Length(B));}
double angle(Point v) {return atan2(v.y,v.x);}
double Cross(Point A,Point B) {return A.x*B.y-A.y*B.x;} Point Rotate(Point A,double rad)
{
return Point(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
} Point GetLineIntersection(Point p,Point v,Point q,Point w)
{
Point u=p-q;
double t=Cross(w,u)/Cross(v,w);
return p+v*t;
} Point getD(Point A,Point B,Point C)
{
Point v1=C-B;
double a1=Angle(A-B,v1);
v1=Rotate(v1,a1/3); Point v2=B-C;
double a2=Angle(A-C,v2);
v2=Rotate(v2,-a2/3); return GetLineIntersection(B,v1,C,v2);
} void read(Point &a)
{
scanf("%lf %lf",&a.x,&a.y);
}
int main()
{
int cas;
scanf("%d",&cas);
while(cas--)
{
Point a,b,c,d,e,f;
read(a);
read(b);
read(c);
d=getD(a,b,c);
e=getD(b,c,a);
f=getD(c,a,b);
printf("%.6f %.6f %.6f %.6f %.6f %.6f\n",d.x,d.y,e.x,e.y,f.x,f.y);
}
return 0;
}
UVA 11178 Morley's Theorem 计算几何模板的更多相关文章
- UVA 11178 Morley's Theorem (计算几何)
题目链接 lrj训练指南 P259 //==================================================================== Point getP( ...
- uva 11178 - Morley's Theorem
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- UVA 11178 Morley's Theorem (坐标旋转)
题目链接:UVA 11178 Description Input Output Sample Input Sample Output Solution 题意 \(Morley's\ theorem\) ...
- UVA 11178 Morley's Theorem(几何)
Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...
- UVa 11178:Morley’s Theorem(两射线交点)
Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...
- UVA 11178 - Morley's Theorem 向量
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- UVA 11178 Morley's Theorem(旋转+直线交点)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543 [思路] 旋转+直线交点 第一个计算几何题,照着书上代码打 ...
- Uva 11178 Morley's Theorem 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- UVa 11178 Morley's Theorem (几何问题)
题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点. 析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点, 以前还得自己算,现在计算机帮你算,更方便, ...
随机推荐
- 云数据库 MariaDB 版
基于MariaDB企业版全球独家合作认证,提供Oracle兼容性及众多企业级数据库特性.支持包括MySQL InnoDB等多种存储引擎,为不同需求的用户提供灵活的选择. 请看视频简介 优势 Oracl ...
- Python_3day
循环 循环是一种控制语句块重复执行的结构 while 适用于广度遍历 for 开发中经常使用 while 循环 当一个条件保持真的时候while循环重复执行语句 while 循环一定要有结束条件, ...
- 学习笔记--最近公共祖先(LCA)的几种求法
前言: 给定一个有根树,若节点\(z\)是两节点\(x,y\)所有公共祖先深度最大的那一个,则称\(z\)是\(x,y\)的最近公共祖先(\(Least Common Ancestors\)),简称\ ...
- Java中的字符串常量池,栈和堆的概念
问题:String str = new String(“abc”),“abc”在内存中是怎么分配的? 答案是:堆内存.(Tips:jdk1.8 已经将字符串常量池放在堆内存区) 题目考查的为Ja ...
- 14、Nginx四层负载均衡
1.Nginx四层负载均衡基本概述 1.1.什么是四层负载均衡 四层负载均衡基于传输层协议包来封装的(如:TCP/IP),那我们前面使用到的七层是指的应用层,它的组装在四层基础之上,无论四层还是七层都 ...
- 月薪 30K Java 程序员,需要掌握哪些技术?
转载自:Java3y 1-5年的Java程序员,薪资区间大致是在15-25K左右,那有没有可能提前达到30K的薪资呢?有人说这只能是大企业或者互联网企业工程师才能拿到.也许是的,小公司或者非互联网企业 ...
- 关于Linux系统下基于Tomcat部署和升级war包的详细过程
1.首先Linux先安装java,Tomcat 中间件规范要求: 1) 软件必须下载到/services/download_soft_v --------(用xftp上传 ...
- label smooth
图像分类的一个trick,推导可参考这位博主https://leimao.github.io/blog/Label-Smoothing/ 知乎上的讨论https://www.zhihu.com/que ...
- magento购物车添加减少数量 实时更新购物车
magento实时更新购物车商品数量 <td> <button onclick="addQtyone();" type="submit"> ...
- session共享原理以及PHP 实现多网站共享用户SESSION 数据解决方案
参考自: http://www.cnblogs.com/qulinke/articles/6003049.html https://segmentfault.com/q/101000000578847 ...