【UVa 11178】Morley's Theorem (计算几何)

本文介绍如何利用计算几何的方法解决Morley定理问题,即通过三角形每个内角的三等分线构造出一个等边三角形,并详细解释了如何计算这个等边三角形顶点的具体坐标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Description

Morley定理:作三角形ABC每个内角的三等分线,相交成三角形DEF,则三角形DEF为等边三角形。

给定A,B,CA,B,C,求D,E,FD,E,F坐标。

Solution

计算几何入门题。
先求出BAC,ABC∠BAC,∠ABC,除以33,将AB旋转求出的角度,得到BF,AF,算出交点FFE,D同理。

Source

/****************************
 * Au: Hany01
 * Prob: UVa11178 Morley's Theorem
 * Date: Feb 9th, 2018
 * Email: hany01@foxmail.com
****************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define rep(i , j) for (int i = 0 , i##_end_ = j; i < i##_end_ ; ++ i)
#define For(i , j , k) for (int i = (j) , i##_end_ = (k) ; i <= i##_end_ ; ++ i)
#define Fordown(i , j , k) for (int i = (j) , i##_end_ = (k) ; i >= i##_end_ ; -- i)
#define Set(a , b) memset(a , b , sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define Mod (1000000007)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr , __VA_ARGS__)
#else
#define debug(...)
#endif

inline void File() {
#ifdef hany01 
    freopen("uva11178.in" , "r" , stdin);
    freopen("uva11178.out" , "w" , stdout);
#endif
}

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read() {
    register char c_; register int _ , __;
    for (_ = 0 , __ = 1 , c_ = getchar() ; !isdigit(c_) ; c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_) ; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

const double eps = 1e-10, Pi = acos(-1.0);
struct Point
{
    double x, y;
    Point(double x = 0, double y = 0): 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 - (Vector A, Vector 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(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 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(Vector v, double rad) { return Vector(v.x * cos(rad) - v.y * sin(rad), v.x * sin(rad) + v.y * cos(rad)); }
Point Projection(Point P, Vector v, Point Q, Vector w) { Vector u = P - Q; return P + v * Cross(w, u) / Cross(v, w); }

Point Solve(Point A, Point B, Point C)
{
    Point F;
    Vector AF, BF;
    double Ang_BAC, Ang_BAF, Ang_ABC, Ang_ABF;
    Ang_BAC = Angle(B - A, C - A);
    Ang_BAF = Ang_BAC / 3;
    AF = Rotate(B - A, Ang_BAF);
    Ang_ABC = Angle(A - B, C - B);
    Ang_ABF = Ang_ABC / 3;
    BF = Rotate(A - B, 2 * Pi - Ang_ABF);
    F = Projection(A, AF, B, BF);
    return F;
}

int main()
{
    File();
    Point A, B, C, D, E, F;
    for (register int T = read(); T --; ) {
        scanf("%lf%lf%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y);
        F = Solve(A, B, C), E = Solve(C, A, B), D = Solve(B, C, A);
        printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n", D.x, D.y, E.x, E.y, F.x, F.y);
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值