1.题目描述:点击打开链接
2.解题思路:本题直接模拟即可。只要知道如何计算D点的坐标,就能算出其他两个点。根据题意,我们需要先计算∠ABC的值a,然后把射线BC逆时针旋转a/3,得到直线BD,同理可以得到直线CD,求交点即可。
3.代码:
//#pragma comment(linker, "/STACK:1024000000,1024000000") #include<iostream> #include<algorithm> #include<cassert> #include<string> #include<sstream> #include<set> #include<vector> #include<stack> #include<map> #include<queue> #include<deque> #include<cstdlib> #include<cstdio> #include<cstring> #include<cmath> #include<ctime> #include<cctype> #include<functional> using namespace std; #define me(s) memset(s,0,sizeof(s)) typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair <int, int> P; 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); } const double eps=1e-10; int dcmp(double x) { if(fabs(x)<eps)return 0; else return x<0?-1:1; } bool operator==(const Point&a,const Point&b) { return dcmp(a.x-b.x)==0&&dcmp(a.y-b.y)==0; } double Dot(Vector A,Vector B) { return A.x*B.x+A.y*B.y; } double Length(Vector A) { return sqrt(Dot(A,A)); } double Angle(Vector A,Vector B) { return acos(Dot(A,B)/Length(A)/Length(B)); } double Cross(Vector A,Vector B) { return A.x*B.y-A.y*B.x; } double Area2(Point A,Point B,Point C) { return Cross(B-A,C-A); } 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; } Point getD(Point A,Point B,Point C) { Vector v1=C-B; double a1=Angle(A-B,v1); v1=Rotate(v1,a1/3); Vector v2=B-C; double a2=Angle(A-C,v2); v2=Rotate(v2,-a2/3); //负数表示逆时针旋转 return GetLineIntersection(B,v1,C,v2); } Point read_point() { double x,y; scanf("%lf%lf",&x,&y); return Point(x,y); } int main() { int T; Point A,B,C,D,E,F; scanf("%d",&T); while(T--) { A=read_point(); B=read_point(); C=read_point(); D=getD(A,B,C); E=getD(B,C,A); F=getD(C,A,B); printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",D.x,D.y,E.x,E.y,F.x,F.y); } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-29 04:35:41