SnellsLawCurve:

Path: Imaging/Optics

% Apply Snell's law of refraction to a curve of the form

   s(1)x^2 + s(2)y^2 + s(3)xy + s(4)x + s(5)y + s(6) = 0 

   A circle of radius 2 with origin [0;0] would have s = [1 1 0 0 0 -4]
   
   If the lens center is on the x axis and its radius is r we get

   (x-x0)^2 + y^2 = r^2

   or [1 1 0 -2x0 0 x0^2-r^2]

   with a ray of the form x = at + x0, y = bt + y0;

   All output vectors are unitized.

   Type SnellsLaw for a demo showing 3 rays hitting a circle.

------------------------------------------------------------------------
   Form:
   [rO, miss] = SnellsLawCurve( r, s, nO, nI, isConcave )
------------------------------------------------------------------------

   ------
   Inputs
   ------
   r               (:)  Ray structure
                         .m  (2,1) [a;b] (slopes)
                         .p  (2,1) [x0;y0]
   s               (1,6) Curve coefficients [x^2 y^2 xy x y 1]
   nO              (1,1) Index of refraction outside
   nI              (1,1) Index of refraction inside
   isConcave       (1,1) 1 = concave default is convex

   -------
   Outputs
   -------
   rO              (:)   Ray structure
                          .m  (2,1) [a;b]  
                          .p  (2,1) [x0;y0]
   miss            (:)   1 if the ray missed

------------------------------------------------------------------------
   Reference: Hanrahan, P. "Refraction"
------------------------------------------------------------------------

Children:

Imaging: Optics/ReflectionLaw
Imaging: Optics/SnellsLaw
Math: Linear/Unit

Back to the Imaging Module page