UVA 11178 /// 向量旋转 两向量夹角
题目大意:
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2119
#include <bits/stdc++.h>
using namespace std; const double eps=1e-;
double add(double a,double b) {
if(abs(a+b)<eps*(abs(a)+abs(b))) return ;
return a+b;
}
struct P {
double x,y;
P(){}
P(double _x,double _y):x(_x),y(_y){}
P operator - (P p) {
return P(add(x,-p.x),add(y,-p.y)); }
P operator + (P p) {
return P(add(x,p.x),add(y,p.y)); }
P operator / (double d) {
return P(x/d,y/d); }
P operator * (double d) {
return P(x*d,y*d); }
double dot (P p) {
return add(x*p.x,y*p.y); }
double det (P p) {
return add(x*p.y,-y*p.x); }
bool operator <(const P& p)const {
return x<p.x || (x==p.x && y<p.y);
}
bool operator ==(const P& p)const {
return abs(x-p.x)<eps && abs(y-p.y)<eps;
}
void read(){
scanf("%lf%lf",&x,&y); }
void ptf() {
printf("%.6f %.6f ",&x,&y); }
}; double lenP(P a) {
return sqrt(a.dot(a));
}
double Angle(P a,P b) {
return acos(a.dot(b)/lenP(a)/lenP(b));
} /// a.dot(b)=|a||b|cos(ang)
P Rotate(P a,double rad) {
P r=P(sin(rad),cos(rad));
return P(a.det(r),a.dot(r));
}
P ins(P a,P v1,P b,P v2) {
P v=a-b;
double t=v2.det(v)/v1.det(v2);
return a+v1*t;
}
P insGet(P a,P b,P c) {
double a1=Angle(a-b,c-b);
P v1=Rotate(c-b,a1/3.0); /// 向量bc绕b逆时针旋转a1/3角度 double a2=Angle(a-c,b-c);
P v2=Rotate(b-c,-a2/3.0); /// 向量cb绕c顺时针旋转a2/3角度
return ins(b,v1,c,v2);
} int main()
{
int t; scanf("%d",&t);
while(t--) {
P a,b,c,d,e,f;
a.read(), b.read(), c.read();
d=insGet(a,b,c);
e=insGet(b,c,a);
f=insGet(c,a,b);
d.ptf(), e.ptf(), f.ptf();
printf("\n");
} return ;
}
UVA 11178 /// 向量旋转 两向量夹角的更多相关文章
- Uva 11178 Morley's Theorem 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- UVA 11178 - Morley's Theorem 向量
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- uva 11178二维几何(点与直线、点积叉积)
Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...
- golang 实现求两向量夹角
type Vector3 struct { X float64 `json:"x"` Y float64 `json:"y"` Z float64 `json: ...
- UVa 11178:Morley’s Theorem(两射线交点)
Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...
- sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)
Rescue The Princess Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Several days ago, a b ...
- 向量旋转 UPC 2217
这道题目是13山东省省赛的签到题,题目大意是给等边三角形的两个定点,让求逆时针旋转之后的第三个点的坐标,原来不会向量的旋转,在网上找了找,找到一篇挺好的,直接贴过来. 向量的旋转 实际做题中我们可能会 ...
- “《编程珠玑》(第2版)第2章”:B题(向量旋转)
B题是这样子的: 将一个n元一维向量向左旋转(即循环移位)i个位置.例如,当n=8且i=3时,向量abcdefgh旋转为defghabc.简单的代码使用一个n元的中间向量在n步内完成该工作.你能否仅使 ...
- Vector3函数理解-计算两向量之间的角度
1.已知两个向量dirA,dirB.Vector3 dirA = new Vector3(-1,1,0); Vector3 dirB = new Vector3(-1,1,1);2.使向量处于同一个平 ...
随机推荐
- int在64位操作系统中占多少位?
仍然是32位. 曾经是这样的:16位操作系统中,int 占16位:在32位操作系统中,int 占32位.但是现在人们已经习惯了 int 占32位,因此在64位操作系统中,int 仍为32位.64位整型 ...
- Go 方法、接口
在 Go 中,类型可以定义接收此类型的函数,即方法.每个类型都有接口,意味着对那个类型定义了方法集合. 下面定义了结构体类型 S 以及它的两个方法: type S struct { i int ...
- JQuery中内容操作函数、validation表单校验
JQuery:内容体拼接(可以直接拼接元素节点和内容节点) JQuery实现: 方案1:A.append(B); == B.appendTo(A);A的后面拼接B 方案2: A.prepend(B); ...
- python 中 random模块的用法
import random print( random.randint(1,10) ) # 产生 1 到 10 的一个整数型随机数 print( random.random() ) # 产生 0 到 ...
- 操作bin目录下的文件
string dir = AppDomain.CurrentDomain.BaseDirectory + "Video"; if (!System.IO.Directory.Exi ...
- web 服务中上传文件大小控制
参考文章:https://rensanning.iteye.com/blog/2388353 项目场景: Vue + Nginx + Java + Tomcat Nginx作为反向代理服务器,访问To ...
- Vue番外篇-路由进阶(一)
Vue的router默认是 export default new Router({ mode: 'history', routes: [ { path: '/', name: 'HelloWorld' ...
- Mybatis中$和#取数据的区别
Mybatis配置中,取出map入参的数据一般有两种方式#{key}和${key},下面是这两种取值的区别: 以同样的语句做对比: <select id="geUserByParam1 ...
- Hadoop–TaskTracker 相关
TaskTracker 是Hadoop集群中运行于各个节点上的服务.他是JobTracker和Task之间的"通信桥梁".一方面它从JobTracker端接受并执行各种命令:比如运 ...
- ZMQ相关
一般来说,做bind的是服务端,做connect的是客服端.zmq的bind和connect与我们通常的socket中bind和connect是不一样的,最起码的,我们它没有启动的先后顺序,而在我们通 ...