UVa 11178 - Morley's Theorem

例题,全是模板,知道了怎么计算,就可以做出来,只是Rotate()函数要注意的是,弧度rad为正时逆时针旋转,为负时顺时针旋转

/*************************************************************************> File Name: UVa11178.cpp> Author: AcToy> Mail: ycsgldy@163.com > Created Time: 2013年07月18日 星期四 15时29分59秒************************************************************************/#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include using namespace std;
typedef unsigned int u32;
typedef long long i64;
typedef unsigned long long u64;
typedef vector IV;
typedef vector BV;
typedef pair II;
typedef vector IIV;
#define For(t,v,c) for(t::const_iterator v=c.begin(); v!=c.end(); ++v)
const int INF = 0x7FFFFFFF;
const double eps = 1E-10;
const double PI = acos(-1);
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 - (Point A, Point 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 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) {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() {double x, y;scanf("%lf%lf", &x, &y);return Point(x, y);
}
int main() {int T;Point A, B, C, D, F, E;scanf("%d", &T);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("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n", D.x, D.y, E.x, E.y, F.x, F.y);}return 0;
}



本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部