UVa 11178 Morley's Theorem
来源:互联网 发布:μcos ii源码v2.86 编辑:程序博客网 时间:2024/05/16 12:01
计算几何使用模板题
#include <cstdio>#include <cmath>#include <iostream>using namespace std;//Templatestruct P { double x, y; P(double x = 0, double y = 0) : x(x), y(y) {} void read() { scanf("%lf%lf", &x, &y); } void print() { printf("%.6f %.6f", x, y); }};typedef P V;V operator + (V a, V b) { return V(a.x+b.x, a.y+b.y);}V operator - (P a, P b) { return V(a.x-b.x, a.y-b.y);}V operator * (V a, double p) { return V(a.x*p, a.y*p);}V operator / (V a, double p) { return V(a.x/p, a.y/p);}const double eps = 1e-10;int dcmp(double x) { if (abs(x) < eps) return 0; else return x < 0 ? -1 : 1;}bool operator == (P a, P b) { return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;}double operator * (V a, V b) { return a.x*b.x + a.y*b.y;}double norm(V a) { return sqrt(a*a);}double det(V a, V b) { return a.x*b.y - a.y*b.x;}double angle(V a, V b) { return acos(a*b / norm(a) / norm(b));}V rotate(V a, double rad) { return V(a.x*cos(rad) - a.y*sin(rad), a.x*sin(rad)+a.y*cos(rad));}//P getLineIntersection(P p, V v, P q, V w) { V u = p - q; double t = det(w, u) / det(v, w); return p + v*t;}//MAINP get(P a, P b, P c) { V v1 = c - b; double a1 = angle(a-b, v1); v1 = rotate(v1, a1/3); V v2; v2 = b - c; double a2 = angle(a-c, v2); v2 = rotate(v2, -a2/3); return getLineIntersection(b, v1, c, v2);}void solve() { P A, B, C; A.read(); B.read(); C.read(); P D = get(A, B, C); P E = get(B, C, A); P F = get(C, A, B); D.print(); cout << ' '; E.print(); cout << ' '; F.print(); cout << endl;}int main() { //freopen("in.txt", "r", stdin); int t; scanf("%d", &t); while (t--) { solve(); }}
0 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-11178Morley'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
- Morley's Theorem UVA
- uclinux很久前笔记12
- Linux操作命令符(基本)
- 18 UI美化自定义形状shape
- 洛谷 P1118 [USACO06FEB] 数字三角形Backward Digit Su…
- booking各地联系方式
- UVa 11178 Morley's Theorem
- JS-验证码倒计时
- 乐乐的部分面试题总结1
- [读书笔记] 深入探索C++对象模型-第四章-Function语义学(中续)
- ListView优化
- 多进程手游流程分析
- 人体呼吸信号的数据挖掘
- 路由器局域网IP(内网IP)和外网IP的关系
- Android Drawable 那些不为人知的高效用法