UVA 11178 - Morley's Theorem 简单的计算几何
2013-10-22 21:18
323 查看
简单的计算几何题目 求出一个d点 其余的点具有相同的解法
#include<cstdio> #include<cmath> #include<algorithm> #define eps 1e-10 using namespace std; 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); } 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 Cross(Vector A, Vector B) { return A.x*B.y -A.y*B.x; } double Angle(Vector A, Vector B) { return acos(Dot(A, B) / Length(A) / Length(B)); } Vector Rotate(Vector A, double 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; } int main() { #ifdef LOCAL freopen("in.txt","r",stdin); #endif // LOCAL int N; scanf("%d",&N); while(N--) { Point a,b,c,d,e,f; scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y); double ang_a,ang_b,ang_c; ang_a = Angle(b-a,c-a); ang_b = Angle(a-b,c-b); ang_c = Angle(a-c,b-c); d = GetLineIntersection(c,Rotate(a-c,2.0*ang_c/3.0),b,Rotate(c-b,1.0*ang_b/3.0)); e = GetLineIntersection(c,Rotate(a-c,1.0*ang_c/3.0),a,Rotate(b-a,2.0*ang_a/3.0)); f = GetLineIntersection(b,Rotate(c-b,2.0*ang_b/3.0),a,Rotate(b-a,1.0*ang_a/3.0)); printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",d.x,d.y,e.x,e.y,f.x,f.y); } return 0; }
相关文章推荐
- UVA - 11178-Morley’s Theorem
- UVA-11178 - Morley's Theorem(计算几何)
- uva 11178 Morley's Theorem 三角形内角三等分线交点
- UVA 11178 - Morley's Theorem(计算几何)
- UVA 11178 || Morley's Theorem (向量旋转求交点
- uva 11178 Morley's Theorem(计算几何-点和直线)
- UVa11178 - Morley's Theorem(向量旋转+直线交点)
- Uva 11178 Morley's Theorem (几何+模拟)
- 【UVa 11178】Morley's Theorem (计算几何)
- UVA 11178 Morley's Theorem(几何)
- UVa 11178 Morley's Theorem (向量旋转)
- Uva - 11178 - Morley's Theorem
- UVA 11178-Morley's Theorem(计算几何_莫雷定理)
- 莫利定理:UVa 11178 Morley's Theorem
- uva 11178 - Morley's Theorem (直线旋转相交)
- uva_11178 Morley's Theorem(计算几何)
- uva11178 Morley's Theorem
- UVA 11178 - Morley's Theorem 向量
- uva 11178 Morley's Theorem 计算几何
- UVA 11178 Morley's Theorem(二维几何基础)