UVA 11178 Morley's Theorem(二维几何基础)

题意:给定一个三角形,求每个角的三等分线相交形成的三角形的三个坐标

题解:直接模板

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <list>
#include <queue>
using namespace std;
#define L(i) i<<1
#define R(i) i<<1|1
const int N = 100005;
const double eps = 1e-10;
struct Point
{
    double x,y;
    Point(double x = 0,double y = 0):x(x),y(y){}
    Point operator +(Point a)
    {
        return Point(x + a.x,y + a.y);
    }
    Point operator -(Point a)
    {
        return Point(x - a.x,y-a.y);
    }
    Point operator *(double p)
    {
        return Point(x * p,y * p);
    }
};
int dcmp(double x)
{
    if(fabs(x) < eps)
        return 0;
    else
        return x < 0 ? -1 : 1;
}
double Dot(Point A,Point B)
{
    return A.x * B.x + A.y * B.y;
}
double Length(Point A)
{
    return sqrt(Dot(A,A));
}
double Angle(Point A,Point B)
{
    return acos(Dot(A,B) / Length(A) / Length(B));
}
double Cross(Point A,Point B)
{
    return A.x*B.y - A.y*B.x;
}
Point Rotate(Point A,double rad)
{
    return Point(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}
Point GetLineIntersection(Point P,Point v,Point Q,Point w)
{
    Point u = P - Q;
    double t = Cross(w,u) / Cross(v,w);
    return P + v*t;
}
Point get(Point A,Point B,Point C)
{
    Point v1 = C-B;
    double a1 = Angle(A-B,v1);
    //printf("%.6lf\n",a1);
    v1 = Rotate(v1,a1/3);
    //printf("%.6lf %.6lf\n",v1.x,v1.y);

    Point v2 = B-C;
    double a2 = Angle(A - C,v2);
    //printf("%.6lf\n",a2);
    v2 = Rotate(v2,-a2/3);
    //printf("%.6lf %.6lf\n",v2.x,v2.y);

    return GetLineIntersection(B,v1,C,v2);
}
int main()
{
    int t,n;
    scanf("%d",&t);
    Point A,B,C,D,E,F;
    while(t--)
    {
        scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
        D = get(A,B,C);
        E = get(B,C,A);
        F = get(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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值