【UVa11178】Morley's Theorem(向量旋转+直线交点)
题目地址:https://vjudge.net/problem/UVA-11178
题目:
给出ABC坐标,求角的三平分线构成的等边三角形的三个顶点的坐标
ac代码:
向量旋转+直线交点
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps = 1e-6;//eps用于控制精度,或者更高精度
const double pi = acos(-1.0);//pi
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 - (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);
}
Vector operator / (Vector a, double p)//向量数除
{return Vector(a.x / p, a.y / p);
}
int dcmp(double x)//精度三态函数(>0,<0,=0)
{if (fabs(x) < eps)return 0; //等于else return x < 0 ? -1 : 1;//小于,大于
}
bool operator == (const Point &a, const Point &b)//向量相等
{return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0;
}
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)//逆时针旋转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;//QPdouble t = Cross(w, u) / Cross(v, w);return P + v * t;
}
Point getPoint(Point A, Point B, Point C)
{Vector BC = C - B, CA = A - C, BA = A - B, CB = B - C;BC = Rotate(BC, Angle(BA, BC)/3.0);CA = Rotate(CA, Angle(CB, CA)*2.0/3.0);return GetLineIntersection(B, BC, C, CA);
}
int main()
{//freopen("/Users/zhangkanqi/Desktop/11.txt","r",stdin);int t;scanf("%d", &t);while(t--){Point A, B, C;double xa, ya, xb, yb, xc, yc;scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &xb, &yb, &xc, &yc);A={xa, ya};B={xb, yb};C={xc, yc};Point D = getPoint(A, B, C);Point E = getPoint(B, C, A);Point F = getPoint(C, A, B);printf("%lf %lf %lf %lf %lf %lf\n", D.x, D.y, E.x, E.y, F.x, F.y);}return 0;
}
【UVa11178】Morley's Theorem(向量旋转+直线交点)相关推荐
- Uva 11178 Morley's Theorem 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- 【第一道计算几何题】 UVA11178 Morley‘s Theorem (二维几何,旋转直线求求交点)
整理的算法模板合集: ACM模板 要求D点我们只需要把直线BC向左旋转a/3,向右旋转b/3得到两直线求交点即可. 秒啊秒啊 解锁技能树--计算几何,终于能加一个计算几何版块了 #include< ...
- UVa 11178:Morley’s Theorem(两射线交点)
Problem D Morley's Theorem Input: Standard Input Output: Standard Output Morley's theorem states tha ...
- UVA 11178 Morley’s Theorem(莫雷定理 计算几何)
Morley's Theorem Input: Standard Input Output: Standard Output Morley's theorem states that that the ...
- UVa 11178 Morley‘s Theorem(计算几何基础)
题目链接:https://www.luogu.com.cn/problem/UVA11178 有 T 组测试样例,输入 3 个点的坐标,A , B , C ,然后每两点确定一条直线,将每两条直线所形成 ...
- 莫利定理:UVa 11178 Morley's Theorem
莫利定理(Morley's theorem),也称为莫雷角三分线定理.将三角形的三个内角三等分,靠近某边的两条三分角线相交得到一个交点,则这样的三个交点可以构成一个正三角形.这个三角形常被称作莫利正三 ...
- Sicily.1059. Exocenter of a Trian(求垂心,向量旋转)
/* 1059. Exocenter of a Trian题目大意: 给出三角形ABC三点坐标,如图所示,作正方形ABDE,正方形BCHJ,正方形CAGF,L为DG中点,M为EJ中点,N为FH中点,直 ...
- java 求两线交点_JAVA求两直线交点和三角形内外心的编程代码
JAVA求两直线交点和三角形内外心的编程代码 一.求两直线交点 复制代码 代码如下: class Point { double x; double y; public Point() { this.x ...
- 【数学基础知识】莫利定理(Morley‘s Theorem)及其直观证明
前两天看了和三角形相关的一个莫利定理,觉得较为有趣,所以做一个记录. 莫利定理(Morley's Theorem) 将三角形的三个内角三等分,靠近某边的两条三分角线相交得到一个交点,则这样的三个交点可 ...
- java 直线交点_[Java教程]谈谈求线段交点的几种算法(js实现,完整版)
[Java教程]谈谈求线段交点的几种算法(js实现,完整版) 0 2014-08-27 10:05:22 "求线段交点"是一种非常基础的几何计算, 在很多游戏中都会被使用到. 下面 ...
最新文章
- webDriver测试百度登录java版
- 解决Ajax不能跨域的方法
- RPC调用链通信方法
- 【英语学习】【WOTD】fantod 释义/词源/示例
- 转载 2020-02-18 在KVM主机和虚拟机之间共享目录
- caffe+CPU︱虚拟机+Ubuntu16.04+CPU+caffe安装笔记
- Ins图片爬取(基于python,selenium)
- CentOS7安装 SGE
- linux下eclipse安装及快捷方式创建
- qt打开xls文件_Qt操作Excel
- maven打包jar包到本地仓库
- vm文件,.vm后缀的文件
- Eth-Trunk(链路聚合)之负载分担模式
- 公交IC卡刷卡数据分析
- 通过L0phtcrack 7进行账号口令破解
- 文件系统(ext2)
- PIV实验流场流速云图(MALAB contour函数用法)
- 任务栏浏览器主页被劫持
- 高通 android笔记本电脑,联想,高通联合推出首款搭载骁龙8cx 5G平台的5G笔记本电脑...
- kubernetes 五种核心资源对象简介
热门文章
- 简单的php商城,简单的php商城
- python判断是否含有0_Python:判断文本中的用户名在数据库中是否存在,存在返回1,不存在返回0...
- ARM开发7.3.3 基础实训( 3 ) 独立式键盘的输入系统设计--LPC21XX
- android 文件上传参数,Android OkHttp Post上传文件并且携带参数实例详解
- python函数调用时所提供的参数可以是常量_如何使用mock作为函数参数在Python中修补常量...
- 事件mousseenter和mouseover的区别
- ajxa TypeError: $.ajax is not a function
- GoJS图表组件简介
- /etc/hosts/中HOSTNAME错误导致SETUP出错
- 浏览器加载、渲染过程总结