UVa 11178 Morley's Theorem (几何问题)
题意:给定三角形的三个点,让你求它每个角的三等分线所交的顶点。
析:根据自己的以前的数学知识,应该很容易想到思想,比如D点,就是应该求直线BD和CD的交点,
以前还得自己算,现在计算机帮你算,更方便,主要注意的是旋转是顺时针还是逆时针,不要搞错了。
要求BD和CD就得先求那个夹角ABC和ACD,然后三等分。
代码如下:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std;
const int maxn = 500 + 10;
const double eps = 1E-10;
struct Point{
double x, y;
Point(double xx = 0, double yy = 0) : x(xx), y(yy) { }
};
typedef Point Vector; Vector operator + (Vector A, Vector B) { return Vector(A.x+B.x, A.y+B.y); }
Vector operator - (Vector A, Vector B) { return Vector(A.x-B.x, A.y-B.y); }
Vector operator * (Vector A, double p) { return Vector(A.x*p, A.y*p); }
double Dot(Vector A, Vector B){ return A.x*B.x + A.y*B.y; }
double Length(Vector A){ return sqrt(Dot(A, A)); }
double Angle(Vector A, Vector B){ return acos(Dot(A, B) / Length(A) / Length(B)); }
double Cross(Vector A, Vector B){ return A.x*B.y - A.y*B.x; }
Vector Rotate(Vector A, double rad){ return Vector(A.x*cos(rad)-A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad)); } Point GetLineIntersection(Point P, Vector v, Point Q, Vector w){
Vector u = P - Q;
double t = Cross(w, u) / Cross(v, w);
return P + v*t;
} Point solve(Point A, Point B, Point C){
double abc = Angle(A-B, C-B) / 3.0;
Vector BD = Rotate(C-B, abc);
double acb = Angle(A-C, B-C) / 3.0;
Vector CD = Rotate(B-C, -acb); return GetLineIntersection(B, BD, C, CD);
} int main(){
int T; cin >> T;
Point A, B, C, D, E, F;
double x, y;
while(T--){
scanf("%lf %lf", &x, &y); A = Point(x, y);
scanf("%lf %lf", &x, &y); B = Point(x, y);
scanf("%lf %lf", &x, &y); C = Point(x, y); D = solve(A, B, C);
E = solve(B, C, A);
F = solve(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(几何)
Morley's Theorem [题目链接]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 (坐标旋转)
题目链接: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
题目传送门 题意:莫雷定理,求三个点的坐标 分析:训练指南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 向量旋转+求直线交点
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 计算几何模板
题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...
随机推荐
- python 文件移动
python实现文件移动: import shutil shutil.move("original_path", "new_folder") # move fi ...
- spring boot 测试类
import org.junit.Test;import org.junit.runner.RunWith;import org.slf4j.Logger;import org.slf4j.Logge ...
- Excel 2003-单元格输入中带记忆功能
最近有个同事问我,如何在Excel单元格输入中带记忆功能?其实很简单: 工具ó选项ó编辑ó将“记忆式键入”项选中ó确定: //附图[效果图]:
- groovy 环境配置
win7: 下载 http://www.groovy-lang.org/download.html 将解压后的文件夹里的bin目录加入path环境变量
- TOMCAT Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
十二月 31, 2014 2:32:45 下午 org.apache.coyote.http11.AbstractHttp11Processor process信息: Error parsing HT ...
- mysql允许某ip访问
grant all on *.* to databaseName@'ipAddress' identified by 'somePassword'; flush privileges;
- C函数指针的用法
1.最简单的用法: #include <cstdio> int (*p)(int);//定义一个函数指针变量p(下面的f其实是一个常量函数指针) int f(int x) { printf ...
- cdoj802-Just a Line
http://acm.uestc.edu.cn/#/problem/show/802 Just a Line Time Limit: 3000/1000MS (Java/Others) Mem ...
- OpenCL、OpenGL、OpenAL
一:OpenCL (全称Open Computing Language,开放运算语言)是第一个面向异构系统通用目的并行编程的开放式.免费标准,也是一个统一的编程环境,便于软件开发人员为高性能计算服务器 ...
- vue-awesome-swiper插件
http://www.cnblogs.com/songrimin/p/6905136.html 这个地址不错 在上一些我的demo代码 第一步安装 npm install vue-awesome-sw ...