uva 11178

时间:2023-03-10 02:54:18
uva 11178

题意:根据A,B,C三点的位置确定D,E,F三个点的位置。

贴模板

 #include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<memory.h>
#include<cstdlib>
#include<vector>
#define clc(a,b) memset(a,b,sizeof(a))
#define LL long long int
using namespace std;
const int N=;
const int inf=0x3f3f3f3f;
const double eps = 1e-; struct Point
{
double x, y;
Point(double x = , double y = ) : 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 - (Point A, Point 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);
} int dcmp(double x)
{
if(fabs(x) < eps) return ;
return x < ? - : ;
} bool operator == (const Point& a, const Point& b)
{
return dcmp(a.x - b.x) == && dcmp(a.y - b.y) == ;
} 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 Area(Point A, Point B, Point C)//三个点组成的三角形的面积
{
return Cross(B - A, C - A);
} Vector Rotate(Vector A, double rad) //向量A逆时针旋转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/); 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--)
{
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);
}
return ;
}