您的位置:首页 > 其它

Morley’s Theorem - UVa 11178 求直线交点

2015-02-18 18:23 381 查看
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



题意:莫利定理(Morley'stheorem),也称为莫雷角三分线定理。将三角形的三个内角三等分,靠近某边的两条三分角线相交得到一个交点,则这样的三个交点可以构成一个正三角形。这个三角形常被称作莫利正三角形。给你三角形ABC的坐标,求DEF的坐标。

思路:因为是三等分线,所以只要求其直线的交点就好,几何模板上。

AC代码如下:

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
usingnamespacestd;
structPoint
{
doublex,y;
Point(doublex=0,doubley=0):x(x),y(y){}
};
typedefPointVector;
Vectoroperator+(VectorA,VectorB){returnVector(A.x+B.x,A.y+B.y);}
Vectoroperator-(VectorA,VectorB){returnVector(A.x-B.x,A.y-B.y);}
Vectoroperator*(VectorA,doublep){returnVector(A.x*p,A.y*p);}
Vectoroperator/(VectorA,doublep){returnVector(A.x/p,A.y/p);}
doubleDot(VectorA,VectorB){returnA.x*B.x+A.y*B.y;}
doubleLength(VectorA){returnsqrt(Dot(A,A));}
doubleAngle(VectorA,VectorB){returnacos(Dot(A,B)/Length(A)/Length(B));}
doubleCross(VectorA,VectorB){returnA.x*B.y-A.y*B.x;}
doubleArea(PointA,PointB,PointC){returnCross(B-A,C-A);}
VectorRotate(VectorA,doublerad)
{returnVector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));}
PointGetLineInterSection(PointP,Vectorv,PointQ,Vectorw)
{
Vectoru=P-Q;
doublet=Cross(w,u)/Cross(v,w);
returnP+v*t;
}
Pointsolve(PointA,PointB,PointC)
{
Vectorv1=C-B;
doublea1=Angle(A-B,v1);
v1=Rotate(v1,a1/3);

Vectorv2=B-C;
doublea2=Angle(A-C,v2);
v2=Rotate(v2,-a2/3);
returnGetLineInterSection(B,v1,C,v2);
}
intmain()
{
intT,t,i,j,k;
PointA,B,C,D,E,F;
scanf("%d",&T);
for(t=1;t<=T;t++)
{
scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
D=solve(A,B,C);
E=solve(B,C,A);
F=solve(C,A,B);
printf("%lf%lf%lf%lf%lf%lf\n",D.x,D.y,E.x,E.y,F.x,F.y);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: