UVA 11178 Morley's Theorem (坐标旋转)
题目链接:UVA 11178
Description
Input
Output
Sample Input
Sample Output
Solution
题意
\(Morley's\ theorem\) 指任意三角形的每个内角的三等分线相交的三角形为等边三角形。
给出三角形的每个点的坐标,求根据 \(Morley's\ theorem\) 构造的等边三角形的三个点的坐标。
题解
对于点 \(D\),只需求直线 \(BC\) 绕点 \(B\) 旋转 \(\frac{1}{3} \angle ABC\) 的直线与直线 \(CB\) 绕点 \(C\) 旋转 \(\frac{1}{3} \angle ACB\) 的直线的交点。其他两点类似。
Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const db eps = 1e-10;
const db pi = acos(-1.0);
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll maxn = 1e5 + 10;
inline int dcmp(db x) {
if(fabs(x) < eps) return 0;
return x > 0? 1: -1;
}
class Point {
public:
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
void input() {
scanf("%lf%lf", &x, &y);
}
Point operator+(const Point a) {
return Point(x + a.x, y + a.y);
}
Point operator-(const Point a) {
return Point(x - a.x, y - a.y);
}
bool operator<(const Point &a) const {
return (!dcmp(y - a.y))? dcmp(x - a.x) < 0: y < a.y;
}
db dis2() {
return x * x + y * y;
}
db dis() {
return sqrt(dis2());
}
db dot(const Point a) {
return x * a.x + y * a.y;
}
db cross(const Point a) {
return x * a.y - y * a.x;
}
db ang(Point a) {
return acos(dot(a) / (a.dis() * dis()));
}
Point Rotate(double rad) {
return Point(x * cos(rad) - y * sin(rad), x * sin(rad) + y * cos(rad));
}
};
typedef Point Vector;
class Line {
public:
Point s, e;
db angle;
Line() {}
Line(Point s, Point e) : s(s), e(e) {}
inline void input() {
scanf("%lf%lf%lf%lf", &s.x, &s.y, &e.x, &e.y);
}
int toLeftTest(Point p) {
if((e - s).cross(p - s) > 0) return 1;
else if((e - s).cross(p - s) < 0) return -1;
return 0;
}
Point crosspoint(Line l) {
double a1 = (l.e - l.s).cross(s - l.s);
double a2 = (l.e - l.s).cross(e - l.s);
double x = (s.x * a2 - e.x * a1) / (a2 - a1);
double y = (s.y * a2 - e.y * a1) / (a2 - a1);
if(dcmp(x) == 0) x = 0;
if(dcmp(y) == 0) y = 0;
return Point(x, y);
}
};
Point get_crosspoint(Point A, Point B, Point C) {
Vector v1 = C - B;
db a1 = v1.ang(A - B);
v1 = v1.Rotate(a1 / 3.0);
v1 = v1 + B;
Vector v2 = B - C;
db a2 = v2.ang(A - C);
v2 = v2.Rotate(-a2 / 3.0);
v2 = v2 + C;
Line l1 = Line(B, v1);
Line l2 = Line(C, v2);
return l1.crosspoint(l2);
}
int main() {
int T;
scanf("%d", &T);
while(T--) {
Point a, b, c;
a.input(); b.input(); c.input();
Point d, e, f;
d = get_crosspoint(a, b, c);
e = get_crosspoint(b, c, a);
f = get_crosspoint(c, a, b);
printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\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 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- 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=8&page=show_problem&p ...
- 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
题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南P259,用到了求角度,向量旋转,求射线交点 /*********************************************** ...
- UVa 11178 Morley's Theorem (几何问题)
题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点. 析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点, 以前还得自己算,现在计算机帮你算,更方便, ...
- UVA 11178 Morley's Theorem 计算几何模板
题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...
随机推荐
- spring MVC 返回值信息和ResponseBody的响应json数据
spring mvc的界面返回: 如果我们定义的返回类型是String 那么我们返回的时候直接写入 我们的界面的名字就可以了 springmvc会自动去找到我们的界面,如果是void类型的返回那么 ...
- 使用 vue.js 的一些操作记录
vue.js不支持ie8以下 1. 在html的属性中赋值: 需要在属性前加上 v-bind
- JS 多个条件判断
// 多个条件判断 // 对象序列(Object) 推荐使用这一种 var obj = {'CJ':'成交', 'WCJ':'未成交'}; if (key in obj) { // TODO } // ...
- WPF常规表单验证
1:ViewModel 实现验证接口 IDataErrorInfo 2:实现接口的相关验证逻辑,并把错误信息反馈给 Error public string this[string columnName ...
- jdk紧急漏洞,XMLDecoder反序列化攻击
昨天在公司发现了一个jdk中的XMLDecoder反序列化的漏洞,看起来很危险!下面通过两个示例来看看这个漏洞的危害! 示例1:利用XmlDecoder删除本地文件 首先来看这个xmldecoder. ...
- DB2命令行查看执行计划
查看对应SQL的执行计划 分析程序包 db2expln -d 数据库名 -i -g -c 模式名-p程序包 -s 0 -t db2expln -d 数据库名 -i -g -c 模式名-p程序包 ...
- go build报错cannot find package
go env 关键数据是这样的 GOPATH="/home/zzy/goProject" GOROOT="/usr/local/go" 项目目录是这样的 goP ...
- Python第九节 条件和循环
while...else 当满足while循环条件的时候执行循环体内的语句,否则执行else的语句例如下面的例子: count = 1 while count <= 5: print(" ...
- css图片文字
1.浏览器是把 html 和 css 一起下载并执行的,计算机里把两件事情同时做 异步加载.计算机中的同步异步和我们生活中的正好是相反的. 补充: 同步,是所有的操作都做完,才返回给用户结果.即写完 ...
- Vue--入门篇
一.v-model和单选按钮(radio) <div id="app"> <input name="sex" value="男&qu ...




