uva 11178 Morley's Theorem
2015-07-18 15:27
477 查看
题意:
Morley定理:作三角形ABC每个内角的三等分线,相交成三角形DEF,则DEF是等边三角形。
你的任务是根据A、B、C3个点的位置确定D、E、F3个点的位置。
分析:
根据三点的坐标,我们可以确定每条三等分线的直线方程P = P0+tv,P0是直线上一点,v是方向向量,t为参数。两两求交点即可得到D、E、F的坐标,求交点的代码参考了刘汝佳的大白书,对于方程是怎么得到的不理解。
以下附上代码:
Morley定理:作三角形ABC每个内角的三等分线,相交成三角形DEF,则DEF是等边三角形。
你的任务是根据A、B、C3个点的位置确定D、E、F3个点的位置。
分析:
根据三点的坐标,我们可以确定每条三等分线的直线方程P = P0+tv,P0是直线上一点,v是方向向量,t为参数。两两求交点即可得到D、E、F的坐标,求交点的代码参考了刘汝佳的大白书,对于方程是怎么得到的不理解。
以下附上代码:
#include <algorithm> #include <iostream> #include <sstream> #include <fstream> #include <cstring> #include <cstdio> #include <vector> #include <cctype> #include <cmath> #include <stack> #include <queue> #include <list> #include <map> #include <set> #include <iomanip> using namespace std; typedef long long ll; typedef unsigned long long ull; struct Point{ double x,y; Point(){} Point(double x_, double y_) : x(x_), y(y_) {} //Point Point operator + (const Point &b) const{ return Point(x+b.x,y+b.y); } Point operator - (const Point &b) const{ return Point(x-b.x,y-b.y); } //Vector Point operator *(double p) const{ return Point(x*p,y*p);; } double operator *(const Point &b) const{//向量点积 return x*b.x+y*b.y; } double operator ^(const Point &b) const{ return x*b.y-y*b.x; } Point rotate(double rad){ return Point(x*cos(rad)-y*sin(rad),x*sin(rad)+y*cos(rad)); } double len(){ return sqrt(x*x+y*y); } }; struct Line{ Point p; Point Vd;//方向向量s Line(){} Line(Point p_,Point Vd_) : p(p_),Vd(Vd_){} }; istream& operator >>(istream &in, Point &b) { in >> b.x >> b.y; return in; } ostream& operator <<(ostream &out, Point &b) { out << b.x << " " << b.y; return out; } double Angle(Point Va, Point Vb) { double x = (Va*Vb)/(Va.len()*Vb.len()); return acos(x); } Point Intersect(Line A, Line B) { Point V = A.p-B.p; double t = (B.Vd^V)/(A.Vd^B.Vd); return A.p+A.Vd*t; } Point getPoint(Point A, Point B, Point C) { double ABC = Angle(A-B,C-B); Line OB(B,(C-B).rotate(ABC/3)); double ACB = Angle(A-C,B-C); Line OC(C,(B-C).rotate(-ACB/3)); return Intersect(OB,OC); } int main() { int t; cin >> t; while(t--){ Point A,B,C; cin >> A >> B >> C; Point D = getPoint(A,B,C); Point E = getPoint(B,C,A); Point F = getPoint(C,A,B); cout << fixed; cout << setprecision(6); cout << D << " " << E << " " << F << "\n"; } return 0; }
相关文章推荐
- sgu288:Best Tournament Schedule(构造)
- 关于vs08生成解决方案慢的解决方法
- Android-真机调试时LogCat不显示的问题
- iOS图片拉伸_小图变大图
- 鼠标悬停在按钮上延时响应OnMouseHover、OnMouseMove和OnMouseLeave
- uva 1658 Admiral (最小费最大流)
- struts拦截器
- ubuntu 下解决“no java virtual machine was found after searching the following locations:” 方法
- prepareCall()执行存储过程
- poj1562 Oil Deposits(简单的深搜)
- ORACLE分页查询
- WebService的两种方式SOAP和REST比较
- this和super的区别
- winPython科学计算平台及NeuroLab库的安装与配置
- pat 1036. Boys vs Girls (25)
- linux页表pgd的含义
- WebService大讲堂之Axis2(8):异步调用WebService
- SCOM2012R2 (5) MONITOR WINDOWS OF WORKGROUP
- 解题思路
- SCOM2012R2 (4) MONITOR LINUX