简单几何(求交点) UVA 11178 Morley's Theorem
2015-10-21 17:01
357 查看
题目传送门
题意:莫雷定理,求三个点的坐标
分析:训练指南P259,用到了求角度,向量旋转,求射线交点
题意:莫雷定理,求三个点的坐标
分析:训练指南P259,用到了求角度,向量旋转,求射线交点
/************************************************ * Author :Running_Time * Created Time :2015/10/21 星期三 15:56:27 * File Name :UVA_11178.cpp ************************************************/ #include <cstdio> #include <algorithm> #include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <list> #include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime> using namespace std; #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 typedef long long ll; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const double EPS = 1e-10; struct Point { double x, y; Point (double x=0, double y=0) : x (x), y (y) {} }; typedef Point Vector; 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; } int dcmp(double x) { if (fabs (x) < EPS) return 0; else return x < 0 ? -1 : 1; } 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 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 point_inter(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 solve(Point a, Point b, Point c) { Vector V1 = c - b; double r1 = angle (a - b, V1); V1 = rotate (V1, r1 / 3); Vector V2 = b - c; double r2 = angle (a - c, V2); V2 = rotate (V2, -r2 / 3); return point_inter (b, V1, c, V2); } int main(void) { int T; scanf ("%d", &T); Point a, b, c, d, e, f; while (T--) { scanf ("%lf %lf %lf %lf %lf %lf", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y); d = solve (a, b, c); e = solve (b, c, a); f = solve (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; }
相关文章推荐
- LSI推多核PowerPC和高速嵌入式DRAM内存模块
- C++中的继承问题
- 第一章 基本语法-5循环(for)
- 安卓集成支付宝支付功能
- 关于Java异常一段很有意思的代码
- Socket网络编程聊天,加多线程
- jQuery File Upload
- Odoo进销存(采购、销售、仓库)入门教程 - 下
- linux系统下网络主-备份策略之网卡bond技术
- 在Javascript中什么是伪数组?如何将伪数组转化为标准数组?
- 从软件工程角度分析毕业设计
- 为何Redis要比Memcached好用(转)
- APP开发及发布流程
- ML
- C语言 数据结构查找 顺序查找及折半查找
- 我想成为一名合格的架构师
- gets()、puts()和fgets()、fputs() 的区别。
- 如何实现JS_MD5加密
- Odoo进销存(采购、销售、仓库)入门教程 - 上
- C#语言和数据库基础