Uva - 11178 - Morley's Theorem
2013-08-29 00:07
399 查看
题意:求Morley定理的3个点的坐标。
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543
——>>照要求做~
#include <cstdio>
#include <cmath>
using namespace std;
struct Point{
double x;
double y;
Point(double x = 0, double y = 0):x(x), y(y){}
}p[3];
typedef Point Vector;
Vector operator + (Point A, Point 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 * (Point A, double p){
return Vector(A.x * p, A.y * p);
}
Vector operator / (Point 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 - B.x * A.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));
}
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;
}
void read(){
for(int i = 0; i < 3; i++) scanf("%lf%lf", &p[i].x, &p[i].y);
}
Point getD(Point A, Point B, Point C){
Vector BC = C - B, BA = A - B;
Vector CB = B - C, CA = A - C;
BC = Rotate(BC, Angle(BC, BA) / 3);
CB = Rotate(CB, -Angle(CB, CA) / 3);
return GetLineIntersection(B, BC, C, CB);
}
void solve(){
Point D, E, F;
D = getD(p[0], p[1], p[2]);
E = getD(p[1], p[2], p[0]);
F = getD(p[2], p[0], p[1]);
printf("%.6f %.6f %.6f %.6f %.6f %.6f\n", D.x, D.y, E.x, E.y, F.x, F.y);
}
int main()
{
int N;
scanf("%d", &N);
while(N--){
read();
solve();
}
return 0;
}
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543
——>>照要求做~
#include <cstdio>
#include <cmath>
using namespace std;
struct Point{
double x;
double y;
Point(double x = 0, double y = 0):x(x), y(y){}
}p[3];
typedef Point Vector;
Vector operator + (Point A, Point 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 * (Point A, double p){
return Vector(A.x * p, A.y * p);
}
Vector operator / (Point 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 - B.x * A.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));
}
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;
}
void read(){
for(int i = 0; i < 3; i++) scanf("%lf%lf", &p[i].x, &p[i].y);
}
Point getD(Point A, Point B, Point C){
Vector BC = C - B, BA = A - B;
Vector CB = B - C, CA = A - C;
BC = Rotate(BC, Angle(BC, BA) / 3);
CB = Rotate(CB, -Angle(CB, CA) / 3);
return GetLineIntersection(B, BC, C, CB);
}
void solve(){
Point D, E, F;
D = getD(p[0], p[1], p[2]);
E = getD(p[1], p[2], p[0]);
F = getD(p[2], p[0], p[1]);
printf("%.6f %.6f %.6f %.6f %.6f %.6f\n", D.x, D.y, E.x, E.y, F.x, F.y);
}
int main()
{
int N;
scanf("%d", &N);
while(N--){
read();
solve();
}
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(几何)
- 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 简单的计算几何
- Uva 11178 Morley's Theorem (几何+模拟)
- UVA 11178 Morley's Theorem
- UVa11178 - Morley's Theorem(向量旋转+直线交点)
- UVa 11178 Morley's Theorem
- UVA 11178 - Morley's Theorem 求坐标