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 < ...
随机推荐
- 66、saleforce 的 approval process
public class TestApproval { public void submitAndProcessApprovalRequest() { // Insert an account Lin ...
- JSON与Java对象的互相转换
JSON与Java对象的互相转换 例一(单个对象进行赋值): @RequestMapping("test1.do") @ResponseBody public JSONObject ...
- PAT_A1033#To Fill or Not to Fill
Source: PAT A1033 To Fill or Not to Fill (25 分) Description: With highways available, driving a car ...
- java 并发——volatile
java 并发--volatile 介绍 维基百科: volatile 是一个类型修饰符(type specifier).volatile 的作用是确保本条指令不会因编译器的优化而省略,且要求每次直接 ...
- volatile在嵌入式系统中的用法
今天参加一家公司的嵌入式C语言笔试,其中有道主观题谈到在嵌入式系统中volatile变量的用法.平时学习C语言没怎么用到,只用到过static和extern的变量,很惭愧没答上来.嵌入式C语言笔试经常 ...
- Python django tests
单元测试函数必须以test_开头,否则无法被识别
- 修改maven包本地默认位置
前言 这段时间上岸了,就有时间整理电脑的资料(强迫症重度患者),就向maven以及gradle的仓库位置动手了. 目的 改变maven的默认位置 步骤 修改maven的配置文件setting.xml( ...
- Java中File类创建文件
只需要调用该类的一个方法createNewFile(),但是在实际操作中需要注意一些事项,如判断文件是否存在,以及如何向新建文件中写入数据等. import java.io.*; public cla ...
- C# 连接Excel,获取表格数据,获取多个sheet中的数据,获取多个sheet名
/// <summary> /// 获取Excel内容. /// </summary> /// <param name="sheetName"> ...
- 2019-5-21-win10-uwp-url-encode
title author date CreateTime categories win10 uwp url encode lindexi 2019-5-21 9:54:7 +0800 2018-2-1 ...