您的位置:首页 > 其它

uva 11178 Morley's Theorem 点线

2013-08-12 10:16 162 查看
Description





ProblemD

Morley’sTheorem

Input:
StandardInput

Output:StandardOutput

Morley’stheoremstatesthatthatthelinestrisectingtheanglesofanarbitraryplanetrianglemeetattheverticesofanequilateraltriangle.Forexampleinthefigurebelowthetri-sectorsofanglesA,BandChasintersectedandcreatedanequilateral
triangleDEF.



Ofcoursethetheoremhasvariousgeneralizations,inparticularifallofthetri-sectorsareintersectedoneobtainsfourotherequilateraltriangles.Butintheoriginaltheoremonlytri-sectorsnearesttoBCareallowedtointersecttogetpointD,tri-sectors
nearesttoCAareallowedtointersectpointEandtri-sectorsnearesttoABareintersectedtogetpointF.TrisectorlikeBDandCEarenotallowedtointersect.SoultimatelywegetonlyoneequilateraltriangleDEF.NowyourtaskistofindtheCartesian
coordinatesofD,EandFgiventhecoordinatesofA,B,andC.

Input
FirstlineoftheinputfilecontainsanintegerN(0<N<5001)whichdenotesthenumberoftestcasestofollow.Eachofthenextlinescontainsixintegers

.Thissix
integersactuallyindicatesthattheCartesiancoordinatesofpointA,BandCare

respectively.YoucanassumethattheareaoftriangleABCisnotequaltozero,

and
thepointsA,BandCareincounterclockwiseorder.

Output

Foreachlineofinputyoushouldproduceonelineofoutput.Thislinecontainssixfloatingpointnumbers

separatedbyasinglespace.Thesesixfloating-point
actuallymeansthattheCartesiancoordinatesofD,EandFare

respectively.Errorslessthan

will
beaccepted.

SampleInputOutputforSampleInput

2

112212

0010005050

1.3169871.8169871.1830131.6830131.3660251.633975

56.69873025.00000043.30127025.00000050.00000013.397460


Problemsetters:ShahriarManzoor

SpecialThanks:JoachimWulff

------------

--------------

/**head-file**/

#include<iostream>
#include<fstream>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<map>
#include<algorithm>

/**define-for**/

#defineREP(i,n)for(inti=0;i<int(n);++i)
#defineFOR(i,a,b)for(inti=int(a);i<int(b);++i)
#defineDWN(i,b,a)for(inti=int(b-1);i>=int(a);--i)
#defineREP_1(i,n)for(inti=1;i<=int(n);++i)
#defineFOR_1(i,a,b)for(inti=int(a);i<=int(b);++i)
#defineDWN_1(i,b,a)for(inti=int(b);i>=int(a);--i)
#defineREP_N(i,n)for(i=0;i<int(n);++i)
#defineFOR_N(i,a,b)for(i=int(a);i<int(b);++i)
#defineDWN_N(i,b,a)for(i=int(b-1);i>=int(a);--i)
#defineREP_1_N(i,n)for(i=1;i<=int(n);++i)
#defineFOR_1_N(i,a,b)for(i=int(a);i<=int(b);++i)
#defineDWN_1_N(i,b,a)for(i=int(b);i>=int(a);--i)

/**define-useful**/

#defineclr(x,a)memset(x,a,sizeof(x))
#definesz(x)int(x.size())
#definesee(x)cerr<<#x<<""<<x<<endl
#definese(x)cerr<<""<<x
#definepbpush_back
#definempmake_pair

/**test**/

#defineDisplay(A,n,m){\
REP(i,n){\
REP(j,m)cout<<A[i][j]<<"";\
cout<<endl;\
}\
}

#defineDisplay_1(A,n,m){\
REP_1(i,n){\
REP_1(j,m)cout<<A[i][j]<<"";\
cout<<endl;\
}\
}

usingnamespacestd;

/**typedef**/

typedeflonglongLL;

/**Add-On**/

constintdirect4[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
constintdirect8[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
constintdirect3[6][3]={{1,0,0},{0,1,0},{0,0,1},{-1,0,0},{0,-1,0},{0,0,-1}};

constintMOD=1000000007;
constintINF=0x3f3f3f3f;
constlonglongINFF=1LL<<60;
constdoubleEPS=1e-9;
constdoubleOO=1e15;
constdoublePI=acos(-1.0);//M_PI;

intdcmp(doublex){
if(fabs(x)<EPS)return0;
returnx>0?1:-1;
}
structpoint{
doublex,y;
point(){}
point(double_x,double_y):x(_x),y(_y){}
/**运算操作**/
booloperator==(pointa)const{
returndcmp(a.x-x)==0&&dcmp(a.y-y)==0;
}
booloperator<(pointa)const{
returndcmp(x-a.x)==0?dcmp(y-a.y)<0:dcmp(x-a.x)<0;
}
friendpointoperator+(pointa,pointb){
returnpoint(a.x+b.x,a.y+b.y);
}//向量+向量=向量
friendpointoperator-(pointa,pointb){
returnpoint(a.x-b.x,a.y-b.y);
}//点-点=向量
friendpointoperator*(pointa,doublep){
returnpoint(a.x*p,a.y*p);
}//向量*数=向量
friendpointoperator/(pointa,doublep){
returnpoint(a.x/p,a.y/p);
}//向量/数=向量
/**基本信息计算**/
doublelen(){
returnhypot(x,y);
}
doublelen2(){
returnx*x+y*y;
}
doubledistance(pointp){
returnhypot(x-p.x,y-p.y);
}
/**向量变换**/
pointrotate(doublerad){
returnpoint(x*cos(rad)-y*sin(rad),x*sin(rad)+y*cos(rad));
}//绕起点逆时针旋转rad
pointrotate(pointp,doubleangle)//绕点p逆时针旋转angle角度
{
pointv=(*this)-p;
doublec=cos(angle),s=sin(angle);
returnpoint(p.x+v.x*c-v.y*s,p.y+v.x*s+v.y*c);
}
pointrotleft(){
returnpoint(-y,x);
}//逆时针转90度
pointrotright(){
returnpoint(y,-x);
}//顺时针转90度
pointnormal(){
doubleL=len();
returnpoint(-y/L,x/L);
}//单位法线即左转90度长度归一
pointtrunc(doubler){
doublel=len();
if(!dcmp(l))return*this;
r/=l;
returnpoint(x*r,y*r);
}//长度变为r
/**读入与输出**/
voidinput(){
scanf("%lf%lf",&x,&y);
}
voidoutput(){
printf("%0.2f%0.2f\n",x,y);
}
};
typedefpointvect;
doubledot(pointa,pointb){
returna.x*b.x+a.y*b.y;
}
doublecross(pointa,pointb){
returna.x*b.y-a.y*b.x;
}
doublearea3p(pointa,pointb,pointc){
returncross(b-a,c-a)/2;
}//三角形abc的面积
doubleangle(vecta,vectb){
returnacos(dot(a,b)/a.len()/b.len());
}
pointGetLineIntersection(pointP,vectv,pointQ,vectw){
vectu=P-Q;
doublet=cross(w,u)/cross(v,w);
returnP+v*t;
}//直线交点
doubleConvexPolygonArea(point*p,intn){
doublearea=0;
for(inti=1;i<n-1;i++)area+=cross(p[i]-p[0],p[i+1]-p[0]);
returnarea/2;
}//多边形面积

structline{
pointa,b;
line(){}
line(point_a,point_b){a=_a;b=_b;}
line(pointp,doubleangle){
a=p;
if(dcmp(angle-PI/2)==0)b=a+point(0,1);
elseb=a+point(1,tan(angle));
}//倾斜角angle
line(double_a,double_b,double_c){
if(dcmp(_a)==0){
a=point(0,-_c/_b);
b=point(1,-_c/_b);
}elseif(dcmp(_b)==0){
a=point(-_c/_a,0);
b=point(-_c/_a,1);
}else{
a=point(0,-_c/_b);
b=point(1,(-_c-_a)/_b);
}
}//ax+by+c=0
voidadjust(){
if(b<a)swap(a,b);
}//两点校准
/**运算操作**/
booloperator==(linev){
return(a==v.a)&&(b==v.b);
}
/**基本信息计算**/
doublelength(){
returna.distance(b);
}
doubleangle(){
doublek=atan2(b.y-a.y,b.x-a.x);
if(dcmp(k)<0)k+=PI;
if(dcmp(k-PI)==0)k-=PI;
returnk;
}
/**线段相关**/
intrelation(pointp){
intc=dcmp(cross(p-a,b-a));
if(c<0)return1;//点在逆时针
if(c>0)return2;//点在顺时针
return3;//平行
}
boolpointonseg(pointp){
returndcmp(cross(p-a,b-a))==0&&dcmp(cross(p-a,p-b))<=0;
}//点p在线段上?
boolparallel(linev){
returndcmp(cross(b-a,v.b-v.a))==0;
}//与线段v平行?
intsegcrossseg(linev){
intd1=dcmp(cross(b-a,v.a-a));
intd2=dcmp(cross(b-a,v.b-a));
intd3=dcmp(cross(v.b-v.a,a-v.a));
intd4=dcmp(cross(v.b-v.a,b-v.a));
if((d1^d2)==-2&&(d3^d4)==-2)return2;
return((d1==0&&dcmp(dot(v.a-a,v.a-b)<=0))||
(d2==0&&dcmp(dot(v.b-a,v.b-b)<=0))||
(d3==0&&dcmp(dot(a-v.a,a-v.b)<=0))||
(d4==0&&dcmp(dot(b-v.a,b-v.b)<=0)));
}//线段相交0-不相交1-非规范相交2-规范相交
/**直线相关**/
intlinecrosseg(linev){//直线v
intd1=dcmp(cross(b-a,v.a-a));
intd2=dcmp(cross(b-a,v.b-a));
if((d1^d2)==-2)return2;
return(d1==0||d2==0);
}//0-平行1-重合2-相交
intlinecrossline(linev){
if((*this).parallel(v))returnv.relation(a)==3;
return2;
}//0-平行1-重合2-相交
pointcrosspoint(linev){
doublea1=cross(v.b-v.a,a-v.a);
doublea2=cross(v.b-v.a,b-v.a);
returnpoint((a.x*a2-b.x*a1)/(a2-a1),(a.y*a2-b.y*a1)/(a2-a1));
}//交点
doubledispointtoline(pointp){
returnfabs(cross(p-a,b-a))/length();
}//点到线的距离
doubledispointtoseg(pointp){
if(dcmp(cross(p-b,a-b))<0||dcmp(cross(p-a,b-a))<0)returnmin(p.distance(a),p.distance(b));
returndispointtoline(p);
}
/**输入输出**/
voidinput(){
a.input();
b.input();
}
voidoutput(){
a.output();
b.output();
}
};

pointgetD(pointA,pointB,pointC){
vectv1=C-B;
doublea1=angle((A-B),v1);
v1=v1.rotate(a1/3);
vectv2=B-C;
doublea2=angle((A-C),v2);
v2=v2.rotate(-a2/3);
returnGetLineIntersection(B,v1,C,v2);
}

intmain()
{
intT;
scanf("%d",&T);
while(T--)
{
pointA,B,C,D,E,F;
A.input();
B.input();
C.input();
D=getD(A,B,C);
E=getD(B,C,A);
F=getD(C,A,B);
printf("%0.6f%0.6f%0.6f%0.6f%0.6f%0.6f\n",D.x,D.y,E.x,E.y,F.x,F.y);
}
return0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: