uva 11178(几何)

就是几何板子,刚学,真恶心。不说了,刘汝嘉牛逼。

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
struct Point
{
    double x,y;
    Point(double a=0,double b=0):x(a),y(b) {}
};
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); }
double Dot(Point A,Point B) { return A.x*B.x+A.y*B.y; }
double Cross(Vector A,Vector B) { return A.x*B.y-A.y*B.x; }
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(Point A,double rad) { return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad)); }
Point Getlineintersectoin(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 rad=Angle(A-B,v1);
    v1=Rotate(v1,rad/3.0);

    Vector v2=B-C;
    rad=Angle(A-C,v2);
    v2=Rotate(v2,-rad/3.0);
    // printf("%.6lf %.6lf\n",v2.x,v2.y);
    Point mm=Getlineintersectoin(B,v1,C,v2);
    return mm;
   // printf("%.6lf %.6lf\n",mm.x,mm.y);
}
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("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",D.x,D.y,E.x,E.y,F.x,F.y);
    }
    return 0;
}

 

posted on 2017-10-18 17:11  发牌员  阅读(197)  评论(0)    收藏  举报

导航