/*
hdu 2857 Mirror and Light
计算几何
镜面反射
*/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
const double DNF=100000001.0;
int t;
double x1,x2,y11,y2,xs,ys,xe,ye;
struct Point
{
double x;
double y;
};
struct Line
{
double a;
double b;
double c;
}; Point get_point1(Line x,Line y)
{
return (Point){ (x.b*y.c-y.b*x.c)/(x.a*y.b-y.a*x.b) , (y.a*x.c-x.a*y.c)/(x.a*y.b-y.a*x.b) };
} Point extent1(Point a,Point b)
{
return (Point){*b.x-a.x,*b.y-a.y};
} Line get_line1(Point a,Point b)
{
return (Line){ a.y-b.y , b.x-a.x , a.y*(a.x-b.x)-a.x*(a.y-b.y) };
} Line get_line1(Point a,Line x)
{
return (Line){ -x.b , x.a , x.b*a.x-x.a*a.y };
} int main()
{
//freopen("1005.in","r",stdin);
scanf("%d",&t);
Point ans;
Point s,e,tmp,m1,m2,news;
Line a,b,c;
while(t--)
{
scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y11,&x2,&y2,&xs,&ys,&xe,&ye);
m1.x=x1;m1.y=y11;
m2.x=x2;m2.y=y2;
s=(Point){xs,ys},e=(Point){xe,ye};
//get
b=get_line1(m1,m2);
a=get_line1(s,b); tmp=get_point1(a,b);
news=extent1(s,tmp);
c=get_line1(news,e);
ans=get_point1(c,b);
if(fabs(ans.x-0.000)<1e-)
ans.x=0.000;
if(fabs(ans.y-0.000)<1e-)
ans.y=0.000;
printf("%.3lf %.3lf\n",ans.x,ans.y);
}
return ;
}

HDU 2857 Mirror and Light的更多相关文章

  1. hdu 2857:Mirror and Light(计算几何,点关于直线的对称点,求两线段交点坐标)

    Mirror and Light Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  2. 「HDU - 2857」Mirror and Light(点关于直线的对称点)

    题目链接 Mirror and Light 题意 一条直线代表镜子,一个入射光线上的点,一个反射光线上的点,求反射点.(都在一个二维平面内) 题解 找出入射光线关于镜子直线的对称点,然后和反射光线连边 ...

  3. hdu 2857 点在直线上的投影+直线的交点

    Mirror and Light Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. 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. ...

  5. 题解 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 ...

  6. 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 ...

  7. HDU 3698 Let the light guide us(DP+线段树)(2010 Asia Fuzhou Regional Contest)

    Description Plain of despair was once an ancient battlefield where those brave spirits had rested in ...

  8. hdu 2857 求点关于线段的对称点

    本来很简单的一个题,但是有个大坑: 因为模板中Tline用到了直线的一般方程ax+by+c=0,所以有种很坑的情况需要特判: 斜率不存在啊喂 老子坑了一下午2333 #include <math ...

  9. HDU 4276-The Ghost Blows Light(树状背包)

    题意: n个房间,每个有一定的钱,一个房间到另一个房间花费一定的时间,给你房间连接树,求在t时间内到达房间m能得到的最大钱数(从房间1(根)出发) 分析: 该题关键是最后要到达m,没有这个条件,就是基 ...

随机推荐

  1. [HDU 1421]搬寝室(富有新意的DP)

    题目地址:pid=1421" target="_blank">http://acm.hdu.edu.cn/showproblem.php? pid=1421 题目大 ...

  2. .NET 开发者必备的工具箱

    本文作者Spencer是一名专注于ASP.NET和C#的程序员,他列举了平时工作.在家所使用的大部分开发工具,其中大部分工具都是集中于开发,当然也有一些其它用途的,比如图片处理.文件压缩等. 如果你是 ...

  3. Windows下Vim主题变更

    默认的好丑! 主题位置. 修改配置文件. 添加主题设置. 新的主题,很高端大气. set fileencodings=utf8,ucs-bom,cp936,big set fileencoding=u ...

  4. sublime-text 编译C

    sublime的优点多多. 先下好sublime-text 如果不会下载 在ubuntu 下输入sudo apt-cache search sublime 查找到合适的安装包后apt-get inst ...

  5. 在Spring Boot中使用Spring-data-jpa实现分页查询

    转自:https://www.cnblogs.com/sandea/p/8275890.html 在我们平时的工作中,查询列表在我们的系统中基本随处可见,那么我们如何使用jpa进行多条件查询以及查询列 ...

  6. 使用python进行re拆分网页内容

    这里简短的总结一下而不是完全的罗列python的re模块,python的re具有强大的功能,如下是一个从我们学校抓取数据然后拆分的程序,代码如下: import httplib import urll ...

  7. js与jquery基础知识对比(一)---2017-05-06

    用表格做的,想要对比的内容一目了然,红色部分为重点   js jquery 取元素 id: document.getElementById("aa"); 取到的是dom对象 cla ...

  8. BZOJ 1531 二进制优化多重背包

    思路: 讲道理我应该写单调队列优化多重背包的 但是我不会啊 但是我现在! 还不会啊 我就写了个二进制优化的.. 过了 //By SiriusRen #include <cstdio> #i ...

  9. LeetCode Weekly Contest 22

    1. 532. K-diff Pairs in an Array 分析:由于要唯一,所以要去重,考虑k=0,时候,相同的数字需要个数大于1,所以,先用map统计个数,对于k=0,特判,对于其他的,遍历 ...

  10. 备忘录模式(Memento)C++实现

    备忘录模式 意图: 在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态.这样以后就可将改对象恢复到原先保存的状态. 适用性: 1.必须保存一个对象在某一个时刻的部分状态,这样以 ...