UVA11178 Morley's Theorem(基础模板)
2016-04-20 17:02
169 查看
题目链接
题意:给出A,B, C点坐标求D,E,F坐标,其中每个角都被均等分成三份
View Code
题意:给出A,B, C点坐标求D,E,F坐标,其中每个角都被均等分成三份
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; struct Point { double x, y; }; typedef Point Vector; Vector operator + (Vector A, Vector B) { Vector C; C.x = A.x + B.x; C.y = A.y + B.y; return C; } Vector operator - (Vector A, Vector B) { Vector C; C.x = A.x - B.x; C.y = A.y - B.y; return C; } Vector operator *(Vector A, double b) { Vector C; C.x = A.x * b; C.y = A.y * b; return C; } Point read_point() { Point temp; scanf("%lf%lf", &temp.x, &temp.y); return temp; } 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)); } Vector Rotate(Vector A, double rad) { Vector C; C.x = A.x * cos(rad) - A.y * sin(rad); C.y = A.x * sin(rad) + A.y * cos(rad); return C; } double Cross(Vector A, Vector B) { return A.x * B.y - A.y * B.x; } 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); } int main() { int T; Point A, B, C, D, E, F; 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; }
View Code
相关文章推荐
- NYOJ 35 表达式求值
- 教你快速使用eclipse开发工具
- linux命令
- sql server 2008数据库连接失败,解决方法
- C++实现string类字符串单词的逆序输出
- access
- 几何-BZOJ-1610-[Usaco2008 Feb]Line连线游戏
- LeetCode *** 264. Ugly Number II (Dynamic Programming )
- POJ3040-Allowance
- 安卓开发画板View
- off() 方法 与 unbind() 方法移除绑定事件的处理程序。one()函数用于为每个匹配元素的一个或多个事件绑定一次性事件处理函数
- js onchange事件,以及setAttribute,getAttribute
- Unable to find the Xcode project `.xcodeproj` for the target `Pods`
- Ambari 常用的 REST API 介绍
- pom文件---详解
- 使用easyUI datagrid的filter时,当value是空时候如何过滤
- [Android教程] android获得json数据并处理
- Unity的DrawCall
- bitnami 版 gitlab 修改端口
- Java之ArrayList源码解读(JDK 1.8)