码迷,mamicode.com
首页 > 其他好文 > 详细

UVA - 11178

时间:2017-10-12 14:07:15      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:can   def   直线   mic   const   include   family   str   cstring   

  存板子(●‘?‘●)

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<cstring>
#include<queue>
#include<set>
#include<string>
#include<map>
#include <complex>
#include <time.h>
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 400+1000;
const int sigma=26;
const ll mod = 1000000007;
const int INF = 0x3f3f3f;
const db eps = 1e-10;
struct point  {
    double x,y;
    point(double x=0,double y=0): x(x),y(y){}
};
typedef point Vector;
Vector operator +(point a,point b)  {
    return Vector(a.x+b.x,a.y+b.y);
}
Vector operator *(point a,double b)  {
    return Vector(a.x*b,a.y*b);
}
Vector operator -(point a,point b)  {
    return Vector(a.x-b.x,a.y-b.y);
}
double dot(Vector a,Vector 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 len(Vector a)  {     //长度
    return sqrt(a.x*a.x+a.y*a.y);
}
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 getans(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 getPoint(point a,point b,point c)  {
    Vector bc=c-b;
    Vector ba=a-b;
    double x=acos(  dot(ba,bc) / len(bc) / len(ba) );
    Vector bd= Rotate(bc,x/3);

    Vector ca=a-c;
    Vector cb=b-c;
    x=acos(  dot(cb,ca) / len(cb) / len(ca) );
    Vector cd=Rotate(cb,-x/3);

    return getans(b,bd,c,cd);
}
void solve() {
    point a,b,c,d,e,f;
    scanf("%lf%lf",&a.x,&a.y);
    scanf("%lf%lf",&b.x,&b.y);
    scanf("%lf%lf",&c.x,&c.y);
    d=getPoint(a,b,c);
    e=getPoint(b,c,a);
    f=getPoint(c,a,b);
    printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",d.x,d.y,e.x,e.y,f.x,f.y);

}
int main() {
    int t = 1;
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    scanf("%d", &t);
    while(t--) {
        solve();
    }
    return 0;
}

 

UVA - 11178

标签:can   def   直线   mic   const   include   family   str   cstring   

原文地址:http://www.cnblogs.com/gggyt/p/7655608.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!