 # physics, laws of refraction

• Dec 7th, 2003, 05:08 PM
Alien_poo
physics, laws of refraction
I need help getting started here. I have two subtsances and light going through both of them. For those who remeber their physics, the light will be refracted with snell-decartes' law. Now I'm trying to represent this on a form, with a line.
Something like the project attached, but I have to recode it myself. Where do I start? My interface is already done.

• Dec 7th, 2003, 05:19 PM
SLH
I'm abit wary of exe's so i'm not gonna run the attached prog, sorry.

What stuff does snell-dertes law give you? An outgoing angle (relative to material divide) given an incoming one? (assuming the density/whatever of the materials are known)

What stuff do you want your program to do? Allow the user to draw vector (line), have it extended to the material devide, and continue with the correct direction?

If so there are several things you're gonna need.

1) A way of getting user input.

The mouse events should be fine.

2) A way of drawing the line.

Not too difficult, simply calculate the formula of the line (using the 2 points give by the user), then work out where along the x axis it should be when y=0 (top of the pic box), and where it should be when y=height of material divide).

3) Drawing the line refracted.

Depending on what the law gives you, this shouldn't be too difficult. It may be a case of simply changing the gradient in the formula, and some x and y values. After that just do something very similar to the first line for drawing it to and from the correct points.

Hope that helped a bit. :)
• Dec 7th, 2003, 05:25 PM
Alien_poo
<QUOTE>What stuff do you want your program to do? Allow the user to draw vector (line), have it extended to the material devide, and continue with the correct direction?</QUOTE>

Yes exactly, but I want two lines extending from the material deivide.... one like you said. and the other would be the light that is reflected.

User input, I have a text box, where the user inputs the second material's density. (the first material is 1 by default). I also have a scroll-bar, which the user can use to give the angle the line hits the 2nd material

The lines are already drawn, but hidden, I guess my program just has to change the X and Y values

and now I have noooo idea how to start, because I can't play around with angles in VB, only with X1, X2, Y1, and Y2
• Dec 7th, 2003, 05:54 PM
SLH
How do you meen the lines are already drawn, I thought what you were asking was how to work out where to draw them?

You can use the following to get the angle when given a triangle.

The opposite (opp) would be the difference in y1 and y2
The Hypotinuse (sp??) would be sqrt(opp2 + adj2)