UVA-11178 - Morley's Theorem(计算几何)

11178


莫雷定理,最早是英国数学家莫勒(Morley)于1904年发现的,内容为三角形三个角的三等分线共有6条,每相邻的(不在同一个角的)两条三等分线的交点,是一个等边三角形的顶点。

让求DEF三点,思路还是很简单的,先求一个点,例D,先用逆转的方法求BD,CD,再求交点。

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double eps = 1e-6;

struct Point
{
    double x,y;
    Point(double xx=0,double yy=0):x(xx),y(yy){}
};
typedef Point Vector;
//#define Vector Point
Vector operator - (Point b, Point a)
{
    return Vector(b.x - a.x, b.y - a.y);
}

Vector operator + (Vector a, Vector p)
{
    return Vector(a.x + p.x, a.y + p.y);
}

Vector operator * (Vector A,double p)
{
    return Vector(A.x*p,A.y*p);
}
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;
}

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/3);
    Vector v2 = B - C;
    double a2 = Angle(A-C,v2);
    v2 = Rotate(v2,-a2/3);
    return GetlineIntersection(B,v1,C,v2);
}

Point read_point()
{
    Point s;
    cin >> s.x >>s.y;
    return s;
}
int main()
{
    int t;
    cin >> t;
    Point A,B,C,D,E,F;
    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("%.6f %.6f %.6f %.6f %.6f %.6f\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、付费专栏及课程。

余额充值