题目大意:

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 /// 向量旋转 两向量夹角的更多相关文章

  1. Uva 11178 Morley's Theorem 向量旋转+求直线交点

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...

  2. UVA 11178 - Morley's Theorem 向量

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  3. uva 11178二维几何(点与直线、点积叉积)

    Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...

  4. golang 实现求两向量夹角

    type Vector3 struct { X float64 `json:"x"` Y float64 `json:"y"` Z float64 `json: ...

  5. UVa 11178:Morley’s Theorem(两射线交点)

    Problem DMorley’s TheoremInput: Standard Input Output: Standard Output Morley’s theorem states that ...

  6. sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)

    Rescue The Princess Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Several days ago, a b ...

  7. 向量旋转 UPC 2217

    这道题目是13山东省省赛的签到题,题目大意是给等边三角形的两个定点,让求逆时针旋转之后的第三个点的坐标,原来不会向量的旋转,在网上找了找,找到一篇挺好的,直接贴过来. 向量的旋转 实际做题中我们可能会 ...

  8. “《编程珠玑》(第2版)第2章”:B题(向量旋转)

    B题是这样子的: 将一个n元一维向量向左旋转(即循环移位)i个位置.例如,当n=8且i=3时,向量abcdefgh旋转为defghabc.简单的代码使用一个n元的中间向量在n步内完成该工作.你能否仅使 ...

  9. Vector3函数理解-计算两向量之间的角度

    1.已知两个向量dirA,dirB.Vector3 dirA = new Vector3(-1,1,0); Vector3 dirB = new Vector3(-1,1,1);2.使向量处于同一个平 ...

随机推荐

  1. js中的函数声明和函数表达式的区别

    目录 一.声明与表达式的格式 1.1 声明式的格式: 1.2 表达式的格式: 二.区别 2.1 函数表达式可以直接在后面加括号执行,而函数声明不可以. 2.2 函数表达式可以被提前解析出来 2.3 命 ...

  2. /etc/fstab修改及mkfs(e2label)相关应用与疑问

    http://blog.chinaunix.net/uid-23392298-id-62318.html 我们将以问题开始说明: 案例: 由于n年前的误操作,导致系统启动的时候,提示如下错误:Coul ...

  3. CSS:CSS 伪元素

    ylbtech-CSS:CSS 伪元素 1.返回顶部 1. CSS 伪元素 CSS伪元素是用来添加一些选择器的特殊效果. 语法 伪元素的语法: selector:pseudo-element {pro ...

  4. on() 不支持hover事件

    因为 .hover() 是 jQuery 自己定义的事件… 是为了方便用户绑定调用 mouseenter 和 mouseleave 事件而已,它并非一个真正的事件,所以当然不能当做 .bind() 中 ...

  5. json 报错415 400

    JS操作JSON总结   $(function(){ $.ajax({ method: 'post', url: '/starMOOC/forum/getSectionList', dataType: ...

  6. build protobuf to a static library

    use ar cd src ar -cvq libprotobuf.a *.o

  7. vue-router 路由配置

    前提: 项目由 vue-cli 脚手架创建. 首先,先下载 vue-router npm install vue-router 安装完成后,运行项目 npm run dev 打开 main.js , ...

  8. Eureka 系列(01)最简使用姿态

    目录 Eureka 系列(01)最简使用姿态 0. Spring Cloud 系列目录 - Eureka 篇 1. 服务发现与发现 1.1 服务发现(Service Discovery) 1.2 服务 ...

  9. 两种接口传送数据协议(xml和json)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/tianyazaiheruan/article/details/37659983    规范性接口开发 ...

  10. Tomcat Architect

    Tomcat Architect Hierarchy of nested tag representing different components in server.xml. 1 <Serv ...