HDU 2857 Mirror and Light
/*
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的更多相关文章
- 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 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 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 ...
- 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 ...
- hdu 2857 求点关于线段的对称点
本来很简单的一个题,但是有个大坑: 因为模板中Tline用到了直线的一般方程ax+by+c=0,所以有种很坑的情况需要特判: 斜率不存在啊喂 老子坑了一下午2333 #include <math ...
- HDU 4276-The Ghost Blows Light(树状背包)
题意: n个房间,每个有一定的钱,一个房间到另一个房间花费一定的时间,给你房间连接树,求在t时间内到达房间m能得到的最大钱数(从房间1(根)出发) 分析: 该题关键是最后要到达m,没有这个条件,就是基 ...
随机推荐
- Create and Call HttpHandler in SharePoint
Create and Call HttpHandler in SharePoint Requirement: 1. Create a httphandler, and reture json data ...
- 程序员(媛)Shell脚本必备技能之中的一个: 在Linux下怎样自己主动备份mysql数据
作者:荀彧(花名) Background:鉴于QAS数据库曾遭到毁灭性损害.极其桑心L.为了避免这样的玉石俱焚的状况再度发生.于是我们找出了一种应对方案.这里给大家分享一下怎样实现定时备份mysql数 ...
- JS遮罩层
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- md5 c# unicode 互换(原创)
php 代码 $input='中国'; $result= md5($input); $temp=iconv("UTF-8", "UTF16LE", $input ...
- javaWeb中URLEncoder.encode编码需要调用两次
今天碰到一个问题,在Controller类中一个方法跳转到该类中的另一个方法,带着中文参数,在跳转之前对该参数进行编码: msg = java.net.URLEncoder.encode(msg,&q ...
- CharSequence源码分析
CharSequence是一个接口,表示一个char值的可读序列,此接口为多种char序列提供统一的.只读的通道.既然是接口,就不能通过new来进行赋值,只能通过以下方式赋值: CharSequenc ...
- Hdu-2892 area 计算几何 圆与凸多边形面积交
题面 题意:有一个凸多边形岛屿,然后告诉你从高空(x,y,h)投下炸弹,爆炸半径r,飞机水平速度和重力加速度,问岛屿被炸了多少 题解:算出来岛屿落地位置,再利用圆与凸多边形面积交 #include&l ...
- if,elif,else的关系 input print int的用法
qian=input("找劳保网是什么网站?:")if qian=="zhaolaobaowang.com": print("正确")els ...
- FTP协议讲解
FTP 概述 文件传输协议(FTP)作为网络共享文件的传输协议,在网络应用软件中具有广泛的应用.FTP的目标是提高文件的共享性和可靠高效地传送数据. 在传输文件时,FTP 客户端程序先与服务器建立连接 ...
- mysql5.7 设置密码
5.7版本的MYSQL的用户表的密码字段与以往版本有所区别, 不再是password字段 而是authentication_string字段. 请注意修改密码: vim /opt/mysql_d/m ...