LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Complicated easy question - ray tracing

Solved!
Go to solution

Hello,

i am working currently on one project - i have an optical system (some prisms, some lenses etc) and i want to make a VI to calculate propagation of a light ray - something like ray tracing.

I know that labview is not the perfect platform to deal with this issue, however i still would like to try.

 

My problem is as following: i want to calculate the propagation of a ray through a lens. I have the ray with some coordinate (y=const) and a plano convex lens - the front of a lens is a piece of a sphere. To calculate the propagation (using snell law) I have to find an angle between the ray and the line which is tangent to this lens-sphere in the point where my light beam hits the lens.

My procedure (on the piece of paper):

 

1.i know the coordinates of a center of a sphere (let's take (0,0)) and its radius r (x^2+y^2=r^2). I know the value of y=y_0 for which the ray enters the lens.

then i can calculate the x_0: x_0^2+y_0^2=r^2. Now i know the point where light enters the lens (x_0,y_0)

2.then just the usual procedure of finding equation for a line tangent to sphere (y=a*x+b):

i put y_0 and x_0 to this equation:

y_0=a*x_0+b

and i can remove one unknown value (for example b): y=a*(x-y_0)+x_0

3.then i put such equation into the equation for sphere (x^2+y^2=r^2) and this is the quadratic equation which has only one unknown value x and one free parameter: a.

4.beacause i want to have tangent line, so it should have only one common point with sphere - so the quadratic equation should have determinant equal to zero (only one solution for x). This gives me an equation for a. I should find the value of a which satisfy this equation and then i know this tangent line and have the solution! uf....

 

Unfortunately i still didn't find a solution to implement this in labview (and i'm motivated beacuse most of the work for this project is already done). I was trying with the formula parsing and so on, but i didn't succeeded. 

 

I will be really grateful for any hints or help!

 

0 Kudos
Message 1 of 9
(4,109 Views)

I have also one idea:

 

i wanted to use polynomial VIs, it will work fine, however i have these unknown parameter a which i want to find in the end. And in polynomial VIs as an input i can use only numbers (double) as coefficients. Is it possible to use somehow these VIs and place some free parameter as an input?

0 Kudos
Message 2 of 9
(4,099 Views)
Solution
Accepted by topic author helmik

helmik,

 

LabVIEW does not do symbolic math.  Once you have the equations solved on paper or reduced to a set which can be solved numerically, tehn you can program it in LV.

 

When I look at your math in the first post, I see that in (3) you describe an equation in x and a. However, this is not a quadratic equation but a fourth order polynomial with terms like a^2*x^2 and 2*a^2*x*y_0. So this is not so easily solved.

 

Is not the tangent to the sphere at right angles to the radius at that point? The angle of the radius can be calculated from x_0 and y_0 and the center of the sphere. Then add 90 degrees. One arctangent and no complicated equations.

 

Lynn

 

 

Message 3 of 9
(4,072 Views)

Hey Lynn,

thank You very much for help and your idea.

Sometimes it's too hard to look for some much easier solutions, when you already have one 😉

 

0 Kudos
Message 4 of 9
(4,062 Views)

helmik,

 

Sometimes it is hard to see the forest for the trees.

 

Glad to be able to offer a dfifferent perspective.

 

Lynn

0 Kudos
Message 5 of 9
(4,044 Views)

Hi Guys,

I neeed help to solve this, appreciate anyone's help

0 Kudos
Message 6 of 9
(4,027 Views)

Liz.b,

 

Your attachment does not actually state what is to be solved!  What are you trying to do? What does this have to do with LabVIEW?  Is this a school assignment?

 

Lynn

0 Kudos
Message 7 of 9
(4,013 Views)

Thanks for the reply, I'm sorry if I posted on wrong forum, actually need to draw the attached image using ray tracing.

 

Liz.

0 Kudos
Message 8 of 9
(4,002 Views)

Liz,

 

This is a Forum for helping people learn to program using LabVIEW, which emphasizes measurements and control.  While you could certainly program ray tracing in LV, I doubt that is what you are wanting to do.  It would be a non-trivial task for an experienced LV programmer and probably almost overwhelming for a beginner.

 

If I have misinterpretted your intent, please clarify what you want.

 

Lynn

0 Kudos
Message 9 of 9
(3,999 Views)