UVA11178 Morley's Theorem(基础模板)

时间:2022-07-31 16:49:48

题目链接

题意:给出A,B, C点坐标求D,E,F坐标,其中每个角都被均等分成三份  UVA11178 Morley's Theorem(基础模板)

求出 ABC的角a, 由 BC 逆时针旋转 a/3 得到BD,然后 求出 ACB 的角a2, 然后 由 BC顺时针 旋转 a2 / 3得到 DC,然后就交点

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
struct Point
{
double x, y;
};
typedef Point Vector;
Vector operator + (Vector A, Vector B)
{
Vector C;
C.x = A.x + B.x;
C.y = A.y + B.y;
return C;
}
Vector operator - (Vector A, Vector B)
{
Vector C;
C.x = A.x - B.x;
C.y = A.y - B.y;
return C;
}
Vector operator *(Vector A, double b)
{
Vector C;
C.x = A.x * b;
C.y = A.y * b;
return C;
}
Point read_point()
{
Point temp;
scanf("%lf%lf", &temp.x, &temp.y);
return temp;
}
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));
}
Vector Rotate(Vector A, double rad)
{
Vector C;
C.x = A.x * cos(rad) - A.y * sin(rad);
C.y = A.x * sin(rad) + A.y * cos(rad);
return C;
}
double Cross(Vector A, Vector B)
{
return A.x * B.y - A.y * B.x;
}
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 / ); Vector v2 = B - C;
double a2 = Angle(A - C, v2);
v2 = Rotate(v2, -a2 / ); return GetLineIntersection(B, v1, C, v2); }
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); }
return ;
}