# Thread: physics, laws of refraction

1. ## 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.  Reply With Quote

2. 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.   Reply With Quote

3. <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  Reply With Quote

4. 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)

sin(angle) = Opp/Hyp

With the angle i guess you can use the laws of refraction and reflaction to get the outgoing angles. Then just use the formulas above to get from the angle to the correct coordinates.  Reply With Quote

5. ok thx, could you also just give me the commands of COS SIN TAN SQUARE ROOT and ABS on a computer?  Reply With Quote

6. well do they exist?  Reply With Quote

7. The VB functions are cos(), sin(), tan() sqr() and abs() respectivly.  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•