题目大意:

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. php开发面试题---Linux常用命令大全

    php开发面试题---Linux常用命令大全 一.总结 一句话总结: ls 查看目录中的文件 cd .. 返回上一级目录 cat 查看文件内容 touch 新建文件或修改时间 1.linux 系统信息 ...

  2. es批量索引

    使用Python操作Elasticsearch数据索引的教程 这篇文章主要介绍了使用Python操作Elasticsearch数据索引的教程,Elasticsearch处理数据索引非常高效,要的朋友可 ...

  3. thinkphp5操作redis系列教程】列表类型之lRange,lGetRange

    <?php namespace app\admin\controller; use think\cache\driver\Redis; use think\Controller; use \th ...

  4. springboot启动失败( No active profile set, falling back to default profiles: default)

    问题: springboot启动失败( No active profile set, falling back to default profiles: default) 解决方法 在pom.xml文 ...

  5. qemu通过命令行直接引导linux内核启动

    qemu -kernel vmlinuz-3.14.0 -hda img_custom -append root=/dev/sda1

  6. flink收藏博客

    1.https://blog.csdn.net/liguohuabigdata/article/category/7279020 2.http://wuchong.me 3.https://www.j ...

  7. Junit用断言对控制台输出进行测试

    核心思路: 在测试前,将标准输出定向到ByteArrayOutputStream中去 用输出流文件断言内容 测试完成,将标准输出修改为console 具体操作示例 基本通用复制粘贴操作 public ...

  8. Codeforces 1173B Nauuo and Chess

    题目链接:http://codeforces.com/problemset/problem/1173/B 思路参考:https://www.cnblogs.com/blowhail/p/1099123 ...

  9. vue 笔记,ref 及 $event 事件对象

    本文仅用作简单记录 ref : 在标签上添加 ref = “name” ,表示获取当前元素节点 <input type="text" ref="info" ...

  10. react-loadable路由懒加载

    load.js import Loadable from 'react-loadable'; import './styles/load.styl' // 按需加载组件 export default ...