/*
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. java根据内容生成二维码图片

    package util; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; ...

  2. 51-nod -1284 2 3 5 7的倍数

    1284 . 2 3 5 7的倍数 基准时间限制:1 秒 空间限制:65536 KB 分值: 5 给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数. 比如N = 10,仅仅有1不是2 3 ...

  3. NSAttributedString宽高计算小技巧

    通常对于CoreText之类自己实现绘制的控件来说,计算富文本的宽高事实上须要依赖CTFramesetterSuggestFrameSizeWithConstraints这种方法. 但有些时候.我们可 ...

  4. luogu1313 计算系数

    题目大意:给定一个多项式(ax+by)^k,请求出多项式展开后x^n*y^m 项的系数. 将原式化为(ax+by)*(ax+by)*...①,然后将其拆解,拆解时x乘了多少次,a就乘了多少次,y,b同 ...

  5. oc14--匿名对象

    // // main.m // 匿名对象 #import <Foundation/Foundation.h> #import "Person.h" #import &q ...

  6. laravel接口设计

    在各种公共方法都设计好,软件安装成功的条件下 routes/web.php中路由信息如下 <?php /* |------------------------------------------ ...

  7. ubuntu查看文件大小

    使用linux命令df 和du,df 但是df只能查看一级文件夹大小.使用比例.档案系统及其挂入点,但对文件却无能为力.du可以查看文件及文件夹的大小.所以基本上是两者配合使用. 一 df h参数, ...

  8. hdoj---Rescue

    Rescue Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submis ...

  9. 2.2.3 修改JSX代码

    /** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { ...

  10. js分享代码

    <<!DOCTYPE html><html><head> <title></title></head> <body& ...