HDU-2857-Mirror and Light(计算几何)
Now, our problem is that, if a branch of light goes into a large and infinite mirror, of course。it will reflect, and leave away the mirror in another direction. Giving you the position of mirror and the two points the light goes in before and after the reflection,
calculate the reflection point of the light on the mirror.
You can assume the mirror is a straight line and the given two points can’t be on the different sizes of the mirror.
The following every four lines are as follow:
X1 Y1
X2 Y2
Xs Ys
Xe Ye
(X1,Y1),(X2,Y2) mean the different points on the mirror, and (Xs,Ys) means the point the light travel in before the reflection, and (Xe,Ye) is the point the light go after the reflection.
The eight real number all are rounded to three digits after the decimal point, and the absolute values are no larger than 10000.0.
1
0.000 0.000
4.000 0.000
1.000 1.000
3.000 1.000
2.000 0.000
#include <stdio.h> void jd(double a1,double b1,double c1,double a2,double b2,double c2,double &x,double &y)//两直线交点
{
x=(b2*c1-b1*c2)/(a1*b2-a2*b1);
y=(a2*c1-a1*c2)/(a2*b1-a1*b2);
} void line(double x1,double y1,double x2,double y2,double &a,double &b,double &c)//两点确定的直线
{
a=y1-y2;
b=x2-x1;
c=x2*y1-x1*y2;
} int main()
{
int T;
double x1,x2,y1,y2,x0,y0,x3,y3,a1,a2,b1,b2,c1,c2,x,y; scanf("%d",&T); while(T--)
{
scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x0,&y0,&x3,&y3); a1=x1-x2;//过(x0,y0)垂直与镜子的直线
b1=y1-y2;
c1=x0*x1-x0*x2+y0*y1-y0*y2; line(x1,y1,x2,y2,a2,b2,c2);//镜子所在直线 jd(a1,b1,c1,a2,b2,c2,x,y);//(x,y)上面两条直线的交点 x+=x-x0;
y+=y-y0; line(x,y,x3,y3,a1,b1,c1); jd(a1,b1,c1,a2,b2,c2,x,y); printf("%.3f %.3f\n",x,y);
}
}
版权声明:本文博主原创文章。博客,未经同意不得转载。
HDU-2857-Mirror and Light(计算几何)的更多相关文章
- HDU 2857 Mirror and Light
/* hdu 2857 Mirror and Light 计算几何 镜面反射 */ #include<stdio.h> #include<string.h> #include& ...
- hdu 2857:Mirror and Light(计算几何,点关于直线的对称点,求两线段交点坐标)
Mirror and Light Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 「HDU - 2857」Mirror and Light(点关于直线的对称点)
题目链接 Mirror and Light 题意 一条直线代表镜子,一个入射光线上的点,一个反射光线上的点,求反射点.(都在一个二维平面内) 题解 找出入射光线关于镜子直线的对称点,然后和反射光线连边 ...
- hdu 2857 点在直线上的投影+直线的交点
Mirror and Light Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 2393:Higher Math(计算几何,水题)
Higher Math Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- HDU 3698 Let the light guide us
Let the light guide us Time Limit: 2000ms Memory Limit: 32768KB This problem will be judged on HDU. ...
- 题解 HDU 3698 Let the light guide us Dp + 线段树优化
http://acm.hdu.edu.cn/showproblem.php?pid=3698 Let the light guide us Time Limit: 5000/2000 MS (Java ...
- HDU 5839 Special Tetrahedron (计算几何)
Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...
- hdu 3698 Let the light guide us(线段树优化&简单DP)
Let the light guide us Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 62768/32768 K (Java/O ...
随机推荐
- Java 泛型具体解释
在Java SE1.5中.添加了一个新的特性:泛型(日本语中的总称型).何谓泛型呢?通俗的说.就是泛泛的指定对象所操作的类型.而不像常规方式一样使用某种固定的类型去指定. 泛型的本质就是将所操作的数据 ...
- VSTO之旅系列(四):创建Word解决方案
原文:VSTO之旅系列(四):创建Word解决方案 本专题概要 引言 Word对象模型 创建Word外接程序 小结 一.引言 在上一个专题中主要为大家介绍如何自定义我们的Excel 界面的,然而在这个 ...
- mongodb分页优化
现在参与一个项目的开发,需要用java查询mongodb数据库,在这里分页用的skip sort 和limit结合,查询语句如下(已经在相关字段建立索引) DBCursor cursor = coll ...
- 组件-------(一)redis系列--安装部署redis+实现redis分布式缓存 java+Spring+redis
目的:解决单机session不能共享问题,插入查询数据库时间效率问题,实现分布式缓存. 准备材料:Redis 下载链接 http://pan.baidu.com/s/1dEGTxvV 相关jar包如果 ...
- hdu4705(树形dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4705 题意: 有一颗树, 选出3个点. 不在同一条路径上的集合数. 分析:这题主要能逆向思考下,用总的 ...
- TCP、UDP和HTTP
先来一个讲TCP.UDP和HTTP关系的 1.TCP/IP是个协议组,可分为三个层次:网络层.传输层和应用层. 在网络层有IP协议.ICMP协议.ARP协议.RARP协议和BOOTP协议. 在传输层中 ...
- shufe前辈名师
前辈名师 姓名 现职/原职 郭秉文 中国现代大学之父.国立东南大学校长.哥伦比亚大学教育学博士,该校第一任校长.为了纪念郭秉文先生,勉励优秀学子,郭夏瑜女士在上海财经大学等校设立了“郭秉文奖学金” 马 ...
- Codeforces #252 (Div. 2) B. Valera and Fruits
题目倒是不难,可是读起来非常恶心 依据题目的描写叙述不easy找到适合存储的方法 后来我就想不跟着出题人的思路走 我自己开一个数组c 令c[a[i]] = b[i] 则c[i] == [j] 代表第i ...
- freemarker导出word带图片
导出word带图片 如果你需要在word中添加图片,那你就在第一步制作模板时,加入一张图片占位,然后打开xml文档,可以看到如下的一片base64编码后的代码: <w:binData w:nam ...
- python学习笔记之四:条件,循环和其他语句
前面已经介绍过几种基本语句(print,import,赋值语句),下面我们来介绍条件语句,循环语句. 一. print和import的更多信息 1.1 使用逗号输出 A.打印多个表达式,用逗号隔开,会 ...