Enjoy the fun of physics with simulations!

Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Title: Light reflected from arbitrary number of mirrorsPost by: Fu-Kwun Hwang on June 30, 2008, 08:50:50 pm
-*-
[ejsapplet] You can use mouse drag and drop to create mirrors (maximum number=36). The first mouse click will be the starting point for the mirror, drag your mouse and drop it at the place you want. You can place mirror at any different locations. (You can drag both end points to change the mirrors later.) And you can change number of rays (uniform distribution in 360 degree). I also add an option for light to be bounded at the boundary. I will leave the rest of work to you! Enjoy it. Question you might asked: How do I know the light hit the mirror and need to be reflected in the simulation. The mirror is a segment which is part of a line. Because I know both end points. So the equation for the line is known. for example: equation for mirror from (x1,y1) to (x2,y2) is y-y1= (y2-y1)/(x2-x1) * (x-x1) Define function f(x,y)= y-y1 - (y2-y1)/(x2-x1) * (x-x1) if the light is located at (xl,yl), then f(xl,yl) is not equal to zero when light is not reach mirror. And the value will be either positive or negative, which depend on light is on which side of the mirror. We can check f(xl,yl) in the simulation, light pass through mirror if the value change sign. So we can find out the contact point and find out the reflected path. More calculations are required to calculated the contact point and reflected path. Is there any one want to know how to do the calculation? Title: Re: Light reflected from arbitrary number of mirrorsPost by: Fu-Kwun Hwang on February 09, 2009, 02:23:54 pm
Some one sent me email asked me how to calculate reflected ray?
Please refer to the attached image. Assume we know the reflect point O, and the incoming vector a ( AO) and the vector b (OB).If only normal vector of b is known, i.e. know the direction but did not know the length.Length | b| can be calculated with inner product between a and unit vector of b'.For example: a=(ax,ay), b'=(bx',by'). Then, the length of OB = (ax*bx'+ay*by')/sqrt(bx'*bx'+by'*by');So you can calculate vector b=(bx,by)=(bx'*OB, by'*OB);Vector AB=AO+OB=a+bThe out going ray OC=OA+AC =-AO+2*AB=2*(a+b)-a=a+2*bBold face represents vector. Title: Re: Light reflected from arbitrary number of mirrorsPost by: curlygrl200 on October 13, 2010, 11:02:50 am
Hi Mr. Hwang,
I'm Arabelle, I posted a message for a code on another simulation. I would like the code for this simulation too. I want to experiment how arranging mirrors in specific shapes can create infinite images. I guess the type of Applet I would like to make is a combination of the two I am asking you for the code. Title: Re: Light reflected from arbitrary number of mirrorsPost by: Fu-Kwun Hwang on October 13, 2010, 12:29:15 pm
The above simulation was created with EJS. You can download EJS source (just click download link below the simulation).
It is an XML format. |