UVA 11178 Morley's Theorem(旋转+直线交点)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543
【思路】
旋转+直线交点
第一个计算几何题,照着书上代码打的。
【代码】
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std; struct Pt {
double x,y;
Pt(double x=,double y=):x(x),y(y) {}
};
typedef Pt vec; vec operator - (Pt A,Pt B) { return vec(A.x-B.x,A.y-B.y); }
vec operator + (vec A,vec B) { return vec(A.x+B.x,A.y+B.y); }
vec operator * (vec A,double p) { return vec(A.x*p , A.y*p); } double cross(vec A,vec B) { return A.x*B.y-A.y*B.x; }
double Dot(vec A,vec B) { return A.x*B.x+A.y*B.y; }
double Len(vec A) { return sqrt(Dot(A,A)); }
double Angle(vec A,vec B) { return acos(Dot(A,B)/Len(A)/Len(B)); } vec rotate(vec A,double rad) {
return vec(A.x*cos(rad)-A.y*sin(rad) , A.x*sin(rad)+A.y*cos(rad));
}
Pt LineIntersection(Pt P,vec v,Pt Q,vec w) {
vec u=P-Q;
double t=cross(w,u)/cross(v,w);
return P+v*t;
}
Pt getD(Pt A,Pt B,Pt C) {
vec v1=C-B;
double a=Angle(A-B,v1);
v1=rotate(v1,a/);
vec v2=B-C;
a=Angle(A-C,v2);
v2=rotate(v2,-a/);
return LineIntersection(B,v1,C,v2);
}
Pt read() {
double x,y;
scanf("%lf%lf",&x,&y);
return Pt(x,y);
}
int main() {
Pt A,B,C,D,E,F;
int T;
scanf("%d",&T);
while(T--) {
A=read() , B=read() , C=read();
D=getD(A,B,C);
E=getD(B,C,A);
F=getD(C,A,B);
printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",D.x,D.y,E.x,E.y,F.x,F.y);
}
return ;
}
UVA 11178 Morley's Theorem(旋转+直线交点)的更多相关文章
- 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(两射线交点)
Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...
- UVA 11178 Morley's Theorem(几何)
Morley's Theorem [题目链接]Morley's Theorem [题目类型]几何 &题解: 蓝书P259 简单的几何模拟,但要熟练的应用模板,还有注意模板的适用范围和传参不要传 ...
- Uva 11178 Morley's Theorem 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- 简单几何(求交点) UVA 11178 Morley's Theorem
题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /*********************************************** ...
- 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 (几何问题)
题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点. 析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点, 以前还得自己算,现在计算机帮你算,更方便, ...
- UVA 11178 Morley's Theorem 计算几何模板
题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...
随机推荐
- js获取当前url参数
//抓取url参数 function GetRequest() { var url = location.search; //获取url中"?"符后的字串 var theReque ...
- Objective-C发展历史
Objective-C发展历史 苹果图标由来: 被咬了一口苹果的LOGO是为了纪念计算机科学的创始人阿兰· 麦席森· 图灵.当年图灵由于身为同性恋者,被强行 "治疗",在被迫注射大 ...
- jQuery仿苏宁易购导航
最近看了些网上的各类导航网站源码,自己学习制作了一个仿苏宁易购的导航栏 jQuery部分代码 $(function(){ $(".CategoryTree>ul>li" ...
- ES 的CRUD 简单操作(小试牛刀)
URL的格式: http://localhost:9200/<index>/<type>/[<id>] 其中index.type是必须提供的. id是可选的,不提供 ...
- upgrade和update的区别
以前一直没搞清这二个词的意思,特别是linux软件管理的时候,用update和upgrade一直没弄明白,后来终于查清: upgrade一般是指比较重要的升级,或者说是主要的,单独版本的升级,其中软件 ...
- 【原创】win7同局域网下共享文件
本文章用于解决win7局域网共享文件问题: 首先保证两台机器可以ping通: 检测方法: win+R输入cmd打开命令行,输入ping 对方主机ip 不知对方ip可以在在命令行中输入ipconfig ...
- frameset标签代码实现网站跳转
js代码1: document.writeln("<frameset rows=\"0, *\">"); document.writeln(&quo ...
- Win7下通过easyBCD引导安装Ubuntu14.04
Ubuntu14.04作为目前最新版本的ubuntu系统,相信很多人都想在自己的电脑上安装一下,然而系统的安装方法各式各样,u盘法.grub引导法等等,这里我将介绍在win7系统下用easyBCD软件 ...
- Linux运维需要掌握的技能 (转)
本人是linux运维工程师,对这方面有点心得,现在我说说要掌握哪方面的工具吧说到工具,在行外可以说是技能,在行内我们一般称为工具,就是运维必须要掌握的工具.我就大概列出这几方面,这样入门就基本没问题了 ...
- 无聊拿socket写的100以内的加法考试。。。
用的广播IP,所以校内网不用设置,直接在校内网随便找台电脑打开服务端,然后再随便找台电脑打开客户端,然后就可以做100以内的加法了... 说明:客户端输入“ready”,服务端会随机发送一条加法算式, ...