UVA 11178 Morley’s Theorem(莫雷定理 计算几何)
2014-09-12 14:45
483 查看
Morley’s
Theorem
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.
Foreachlineofinputyoushouldproduceonelineofoutput.Thislinecontainssixfloatingpointnumbers
题意:作三角形ABC每个内角的三等分线,相交成三角形DEF,则DEF是等边三角形。给出A、B、C3个的位置确定D、E、F3个点的位置。
分析:本题没什么算法可言,只要根据题意计算。考虑到对称性,只需要知道如何求D点即可。首先需要计算角ABC的值a,然后把射线BC逆时针旋转a/3,得到直线BD,同理可以得到直线CD,求出交点即可。
Theorem
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.
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 |
分析:本题没什么算法可言,只要根据题意计算。考虑到对称性,只需要知道如何求D点即可。首先需要计算角ABC的值a,然后把射线BC逆时针旋转a/3,得到直线BD,同理可以得到直线CD,求出交点即可。
#include<cstdio>
#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-(PointA,PointB){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);}
booloperator<(constPoint&a,constPoint&b){
returna.x<b.x||(a.x==b.x&&a.y<b.y);
}
constdoubleeps=1e-10;
intdcmp(doublex){
if(fabs(x)<eps)return0;
returnx<0?-1:1;
}
booloperator==(constPoint&a,constPoint&b){
returndcmp(a.x-b.x)==0&&dcmp(a.y-b.y)==0;
}
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){//向量A逆时针旋转rad弧度后的坐标
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;
}
PointgetD(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;
PointA,B,C,D,E,F;
scanf("%d",&T);
while(T--){
scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
D=getD(A,B,C);
E=getD(B,C,A);
F=getD(C,A,B);
printf("%lf%lf%lf%lf%lf%lf\n",D.x,D.y,E.x,E.y,F.x,F.y);
}
return0;
}
相关文章推荐
- 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 计算几何
- UVA 11178 Morley's Theorem(二维几何基础)
- UVA 11178 || Morley's Theorem (向量旋转求交点
- uva 11178 - Morley's Theorem (直线旋转相交)
- UVa11178 - Morley's Theorem(向量旋转+直线交点)
- 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(几何)
- UVA 11178 Morley’s Theorem(二维计算几何基础)
- 莫利定理:UVa 11178 Morley's Theorem
- uva11178 Morley's Theorem
- UVA 11178 - Morley's Theorem 向量
- uva 11178 Morley's Theorem(计算几何-点和直线)
- UVa 11178 Morley's Theorem(几何)