/*
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. 使用 AFNetworking的时候,怎样管理 session ID

    问: As the title implies, I am using AFNetworking in an iOS project in which the application talks to ...

  2. DotNetBar.Bar菜单的使用

    DotNetBar.Bar菜单的使用 老帅     在C#中使用控件DevComponents.DotNetBar.Bar时,怎样设计菜单呢?      1.拖放生成一个菜单容器      拖放一个D ...

  3. luogu1072 Hankson的趣味题

    题目大意 给出数a0, a1, b0, b1,求满足gcd(a0, x)=a1, lcm(b0, x)=b1的x的个数 解法一 枚举b1的因数,看看是否满足上述条件. 怎样枚举因数 试除法.对于1~s ...

  4. Spring如何加载XSD文件(org.xml.sax.SAXParseException: Failed to read schema document错误的解决方法)

    今天配置Spring的xml出现了错误 Multiple annotations found at this line: - schema_reference.4: Failed to read sc ...

  5. h5-9 canvas

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. 现代英特尔® 架构上的 TensorFlow* 优化——正如去年参加Intel AI会议一样,Intel自己提供了对接自己AI CPU优化版本的Tensorflow,下载链接见后,同时可以基于谷歌官方的tf版本直接编译生成安装包

    现代英特尔® 架构上的 TensorFlow* 优化 转自:https://software.intel.com/zh-cn/articles/tensorflow-optimizations-on- ...

  7. AWS S3 对象存储服务

    虽然亚马逊云非常牛逼,虽然亚马逊云财大气粗,虽然亚马逊用的人也非常多,可是这个文档我简直无法接受,特别是客服,令人发指的回复速度,瞬间让人无语,可是毕竟牛逼.忍了,躺一次坑而已 1.图片上传 1.1 ...

  8. 2.Ventuz Designer常用工具介绍

    Ventuz Designer常用工具介绍 1.  打开Ventuz Designer 图1.1 2.  Ventuz Designer第一个界面 图2.1 Recent Projects:最近创建的 ...

  9. C# DataTable常用方法总结

    https://blog.csdn.net/wangzhen209/article/details/51743118

  10. 图片文字滚动插件jQuery Scrollbox

    图片文字滚动插件jQuery Scrollbox附件中提供了五种图片.文字滚动样式,只需调用jquery库和jQuery Scrollbox插件,然后再加一段简单的jquery代码即可使用,兼容性良好 ...