HDU-2857-Mirror and Light(計算幾何),計算幾何

來源:互聯網
上載者:User

HDU-2857-Mirror and Light(計算幾何),計算幾何
Problem DescriptionThe 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. 
InputThe 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. 
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 <stdio.h>void jd(double a1,double b1,double c1,double a2,double b2,double c2,double &x,double &y)//兩直線交點{    x=(b2*c1-b1*c2)/(a1*b2-a2*b1);    y=(a2*c1-a1*c2)/(a2*b1-a1*b2);}void line(double x1,double y1,double x2,double y2,double &a,double &b,double &c)//兩點確定的直線{    a=y1-y2;    b=x2-x1;    c=x2*y1-x1*y2;}int main(){    int T;    double x1,x2,y1,y2,x0,y0,x3,y3,a1,a2,b1,b2,c1,c2,x,y;    scanf("%d",&T);    while(T--)    {        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x0,&y0,&x3,&y3);        a1=x1-x2;//過(x0,y0)垂直與鏡子的直線        b1=y1-y2;        c1=x0*x1-x0*x2+y0*y1-y0*y2;        line(x1,y1,x2,y2,a2,b2,c2);//鏡子所在直線        jd(a1,b1,c1,a2,b2,c2,x,y);//(x,y)上面兩條直線的交點        x+=x-x0;        y+=y-y0;        line(x,y,x3,y3,a1,b1,c1);        jd(a1,b1,c1,a2,b2,c2,x,y);        printf("%.3f %.3f\n",x,y);    }}

light and shadow

特殊的片語,你得特別區分記憶,不能一概而論~
knive and fork 改 knife and fork
 
Light And Shadow 歌詞

歌曲名:Light And Shadow
歌手:Vangelis
專輯:Reprise 1990-1999

Light and Shadow
詞 曲:岡野昭仁
ポルノグラフィティ
夜空には心の跡
煌めいて流星が落ちる
靜けさと波立つ色は so blue
掌に握りしめた弱気な想い舍てられずに
夜明け前 瀕死の僕を蘇生してくれ
キスなんて無駄なのさ
心が濡れていない
さよなら さなぎのままの yesterday
今日で最後にするんだ
かよわい羽広げ大地を蹴り出すカが欲しい
空気をつかみ 身體を預け
流れのままに 漂ってみるだけ
そしていつかは君のもとへと辿り著いてる
何億年も輝いてる
太陽は笑っていた
彼にとって滑稽なんだろう
影になること
陽はの升り落ちて
また僕を隠すんだ
抱けしめて僕をもっと身體ごと覆い盡くして
風のように 海のように
夢のように 運命のように
両手から足先に系がる赤い血液を巡らせ
震える心で叫びたい
さよなら さなぎのままの yesterday
誰かのせいにしないで
僕の中で眠った未來をもう一度見つめてみよう
光を集め 目を逸らずに 古くなってても
また磨けばいい
きっと必ず扉は開き飛び立てるだろう

music.baidu.com/song/10359168
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.