杭电 2857 计算几何
来源:互联网 发布:外汇黄金走势软件 编辑:程序博客网 时间:2024/06/07 16:29
留下做个模板。。。。。。。。题目:
Mirror and Light
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 410 Accepted Submission(s): 187
Problem Description
The light travels in a straight line and always goes in the minimal path between two points, are the basic laws of optics.
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.
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.
Input
The first line is the number of test case t(t<=100).
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.
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.
Output
Each lines have two real number, rounded to three digits after the decimal point, representing the position of the reflection point.
Sample Input
10.000 0.0004.000 0.0001.000 1.0003.000 1.000
Sample Output
2.000 0.000
#include <iostream>#include <cstdio>using namespace std;int main(){ int numcase; double x1,y1,x2,y2,xs,ys,xe,ye,x0,y0,a,b,c; scanf("%d",&numcase); while(numcase--){ scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&xs,&ys,&xe,&ye);a=y2-y1;b=x1-x2;c=(x2-x1)*y2-(y2-y1)*x2;x0=((b*b-a*a)*xs-2*a*b*ys-2*a*c)/(a*a+b*b);//对称点横坐标y0=((a*a-b*b)*ys-2*a*b*xs-2*b*c)/(a*a+b*b);//对称点纵坐标//两条直线交点double k=((x0-xe)*(y1-ye)-(y0-ye)*(x1-xe))/((y0-ye)*(x2-x1)-(x0-xe)*(y2-y1));double xx=x1+k*(x2-x1);double yy=y1+k*(y2-y1);printf("%.3lf %.3lf\n",xx,yy); } return 0;}
- 杭电 2857 计算几何
- 杭电2037 计算几何
- 杭电1086(计算几何)解题报告
- 杭电 hdu 5563(计算几何)(思维)(判断是否为五角星)
- 杭电-5858-几何,思维
- 计算几何几何函数库
- 计算几何-几何库
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- 计算几何
- Android屏蔽home键的代码,咋摁也不响应的方法
- Struts1.3-DispatchAction类-根据请求参数实现业务分派
- Android中使用ListView以及在Listview中添加CheckBox时若干问题
- XTU 1095 连续自然数和
- PHP缓存opcode加速之APC配置使用介绍 (深入理解)
- 杭电 2857 计算几何
- 关于DN名称乱码的解决办法!
- DBGridEh的事件备忘
- Android模拟器增大内存的方法
- InstallShield安装新版本时卸载老版本
- JavaScript脚本代码大全
- Nand Flash与Nor Flash
- Android 4.0设计规范的10大改变
- 递归打印某个对象所在继承体系中的所有类及声明的属性