UVAOJ 11178——Morley’s Theorem
2014-03-28 07:53
387 查看
这是一道计算几何的模板题,求点D的时候,就把角ABC求出来,然后除以三,然后把BC边旋转一下,同理求出BCA的度数,然后除以三,再把CB旋转一下,两个旋转以后的交点就是D。用同样的方法求出E和F。
代码如下:
代码如下:
#include<iostream> #include<iomanip> #include<cmath> using namespace std; struct point{ double x,y; point (double x=0,double y=0):x(x),y(y){ } }; 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);} vector operator /(vector A,double p){return vector (A.x/p,A.y/p);} bool operator <(const point& a,const point &b){ return a.x<b.x||(a.x==b.x&&a.y<b.y); } bool operator ==(const point &a,const point &b){ return (a.x==b.x)&&(a.y==b.y); } double dot(vector a,vector b){ return a.x*b.x+a.y*b.y; } double lenth(vector a){ return sqrt(dot(a,a)); } double cross(vector a,vector b){ return a.x*b.y-a.y*b.x; } double angle(vector a,vector b){ return acos(dot(a,b)/lenth(a)/lenth(b)); } 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; } int main(){ ios::sync_with_stdio(false); // freopen("data.txt","r",stdin); int n; cin>>n; while(n--){ point A,B,C; cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y; point D; double ABC=angle((A-B),C-B); ABC/=3; vector BD=rotate(C-B,ABC); double BCA=angle(A-C,B-C); BCA/=3; vector CD=rotate(B-C,-BCA); D=getlineintersection(B,BD,C,CD); point F; vector BF=rotate(BD,ABC); double BAC=angle(B-A,C-A); BAC/=3; vector AF=rotate(B-A,BAC); F=getlineintersection(A,AF,B,BF); vector AE=rotate(AF,BAC); vector CE=rotate(A-C,BCA); point E=getlineintersection(A,AE,C,CE); cout<<setiosflags(ios::fixed)<<setprecision(6)<<D.x<<' '<<D.y<<' '<<E.x<<' '<<E.y<<' '<<F.x<<' '<<F.y<<endl; } return 0; }
相关文章推荐
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- UVA 11178 Morley's Theorem——直线相交
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- UVA 11178 Morley's Theorem
- UVAoj 11178 Morley's Theorem
- Morley's Theorem UVA - 11178
- uva 11178 Morley's Theorem 点线
- UVA 11178 Morley's Theorem .
- Morley's Theorem UVA - 11178
- UVA - 11178-Morley’s Theorem
- Morley's Theorem UVA - 11178
- UVA 11178 - Morley's Theorem 向量
- uva 11178 Morley's Theorem
- UVA 11178 Morley's Theorem(二维几何基础)
- UVA 11178 Morley's Theorem
- Uva - 11178 - Morley's Theorem