ray tracing  how to numerically integrate the equation of the rayby carloscarlos Tags: equation, integrate, numerically, tracing 

#1
Dec112, 09:10 AM

P: 4

In a continuous isotropic medium having refractive index n, (not constant)
the ray path can be described by the following equation d/ds(n dr/ds)) = grad (n) with an obvious meaning of the symbols (for they who can help me!). I wrote a code to calculate the ray path. I found result qualitatively consistent but not quantitatively. I think that the integration procedure I used is wrong (I used a simple one, that I set up on my own). Can anybody help me? Can anybody suggest me a paper or book where to read an algorithm? Has anybody a source code to integrate it? (I would need just the core instructions). Thanks Bye 



#2
Dec112, 10:31 AM

Sci Advisor
P: 2,470

Just to make sure, the equation you are actually integrating over is the following, correct?
[tex]\frac{d}{ds}\frac{dr}{ds} = \nabla n  \left(\nabla n \cdot \frac{dr}{ds}\right)\frac{dr}{ds}[/tex] Note that dr/ds is just a unit vector you want as function of s, and the above equation maintains unit length of the vector. So the thing you should check in your code is if dr/ds = 1 all the way along the path. If not, you either have an error in the method or the code. Now, not knowing specifically the kind of function you have for n(r), it's a little hard to say how advanced a method you should be using, but if brute force forward Euler is not working for you, try one of the higher order Runge Kutta methods. 


Register to reply 
Related Discussions  
numerically evaluating an equation  Calculus  0  
How can I integrate this ODE numerically?  Differential Equations  1  
Reversetracing Einstein's field equation  Special & General Relativity  11  
Numerically solving NLS equation  Differential Equations  1  
Solving an Equation Numerically  General Math  6 