File:Shack-Hartmann.gif

Summary

Description
English: A Shack-Hartmann sensor is made my an array of small lenses and a camera. If the light hitting the lenses is collimated, we will get a number of equispaced foci on the camera. But if the light is not collimated, the position of the foci will change in a predictable way, so we can reconstruct where the ray were coming from.
Date
Source https://mathstodon.xyz/@j_bertolotti/114557956224616668
Author Clodovendro
Permission
(Reusing this file)
https://mathstodon.xyz/@j_bertolotti/114533575175127912

Mathematica 14.0 code

rlens = 1; nlens = 10; f = 2;
lensy = Table[y, {y, -(nlens - 1)/2, (nlens - 1)/2, 2*rlens}];
rspacing = 0.2; (*tentative value*)
radii = Table[r, {r, -rlens + rspacing/2, rlens, rspacing}];
nrays = Dimensions[radii][[1]]*Dimensions[lensy][[1]];
frames1 = Table[
   \[Theta]in = 
    Table[\[Pi]/50*Sin[\[Pi]/2 t]^2, {r, radii}, {y, lensy}];
   Graphics[{
     Thick, Yellow, 
     Table[Line[{10 {-Cos[\[Theta]in[[r, y]]], 
           Sin[\[Theta]in[[r, y]]]} + {0, 
          radii[[r]] + lensy[[y]]}, {0, 
         radii[[r]] + lensy[[y]]}}], {r, 1, 
       Dimensions[radii][[1]]}, {y, 1, Dimensions[lensy][[1]]}],
     Table[
      Line[{{0, radii[[r]] + lensy[[y]]}, 
        10 {Cos[\[Theta]in[[r, y]] + radii[[r]]/
             f], -Sin[\[Theta]in[[r, y]] + radii[[r]]/f]} + {0, 
          radii[[r]] + lensy[[y]]}}], {r, 1, 
       Dimensions[radii][[1]]}, {y, 1, Dimensions[lensy][[1]]}]
     ,
     Gray, Table[Ellipsoid[{0, y}, {0.2, rlens}], {y, lensy}]
     }, PlotRange -> {{-10, 1.5 f}, {-(nlens/2)*rlens - 1, 
       nlens/2*rlens}}, Background -> Black]
   , {t, 0, 1, 0.1}];
frames2 = Table[
   \[Theta]in = 
    Table[-(\[Pi]/50)*Sin[\[Pi]/2 t]^2, {r, radii}, {y, lensy}];
   Graphics[{
     Thick, Yellow, 
     Table[Line[{10 {-Cos[\[Theta]in[[r, y]]], 
           Sin[\[Theta]in[[r, y]]]} + {0, 
          radii[[r]] + lensy[[y]]}, {0, 
         radii[[r]] + lensy[[y]]}}], {r, 1, 
       Dimensions[radii][[1]]}, {y, 1, Dimensions[lensy][[1]]}],
     Table[
      Line[{{0, radii[[r]] + lensy[[y]]}, 
        10 {Cos[\[Theta]in[[r, y]] + radii[[r]]/
             f], -Sin[\[Theta]in[[r, y]] + radii[[r]]/f]} + {0, 
          radii[[r]] + lensy[[y]]}}], {r, 1, 
       Dimensions[radii][[1]]}, {y, 1, Dimensions[lensy][[1]]}]
     ,
     Gray, Table[Ellipsoid[{0, y}, {0.2, rlens}], {y, lensy}]
     }, PlotRange -> {{-10, 1.5 f}, {-(nlens/2)*rlens - 1, 
       nlens/2*rlens}}, Background -> Black]
   , {t, 0, 1, 0.1}];
frames3 = Table[
   \[Theta]in = 
    Table[(r + y)/50*Sin[\[Pi]/2 t]^2, {r, radii}, {y, lensy}];
   Graphics[{
     Thick, Yellow, 
     Table[Line[{10 {-Cos[\[Theta]in[[r, y]]], 
           Sin[\[Theta]in[[r, y]]]} + {0, 
          radii[[r]] + lensy[[y]]}, {0, 
         radii[[r]] + lensy[[y]]}}], {r, 1, 
       Dimensions[radii][[1]]}, {y, 1, Dimensions[lensy][[1]]}],
     Table[
      Line[{{0, radii[[r]] + lensy[[y]]}, 
        10 {Cos[\[Theta]in[[r, y]] + radii[[r]]/
             f], -Sin[\[Theta]in[[r, y]] + radii[[r]]/f]} + {0, 
          radii[[r]] + lensy[[y]]}}], {r, 1, 
       Dimensions[radii][[1]]}, {y, 1, Dimensions[lensy][[1]]}]
     ,
     Gray, Table[Ellipsoid[{0, y}, {0.2, rlens}], {y, lensy}]
     }, PlotRange -> {{-10, 1.5 f}, {-(nlens/2)*rlens - 1, 
       nlens/2*rlens}}, Background -> Black]
   , {t, 0, 1, 0.1}];
frames4 = Table[
   \[Theta]in = 
    Table[-((r + y)/50)*Sin[\[Pi]/2 t]^2, {r, radii}, {y, lensy}];
   Graphics[{
     Thick, Yellow, 
     Table[Line[{10 {-Cos[\[Theta]in[[r, y]]], 
           Sin[\[Theta]in[[r, y]]]} + {0, 
          radii[[r]] + lensy[[y]]}, {0, 
         radii[[r]] + lensy[[y]]}}], {r, 1, 
       Dimensions[radii][[1]]}, {y, 1, Dimensions[lensy][[1]]}],
     Table[
      Line[{{0, radii[[r]] + lensy[[y]]}, 
        10 {Cos[\[Theta]in[[r, y]] + radii[[r]]/
             f], -Sin[\[Theta]in[[r, y]] + radii[[r]]/f]} + {0, 
          radii[[r]] + lensy[[y]]}}], {r, 1, 
       Dimensions[radii][[1]]}, {y, 1, Dimensions[lensy][[1]]}]
     ,
     Gray, Table[Ellipsoid[{0, y}, {0.2, rlens}], {y, lensy}]
     }, PlotRange -> {{-10, 1.5 f}, {-(nlens/2)*rlens - 1, 
       nlens/2*rlens}}, Background -> Black]
   , {t, 0, 1, 0.1}];
frames5 = Table[
   \[Theta]in = 
    Table[Sin[2 (r + y)]/25*Sin[\[Pi]/2 t]^2, {r, radii}, {y, 
      lensy}];
   Graphics[{
     Thick, Yellow, 
     Table[Line[{10 {-Cos[\[Theta]in[[r, y]]], 
           Sin[\[Theta]in[[r, y]]]} + {0, 
          radii[[r]] + lensy[[y]]}, {0, 
         radii[[r]] + lensy[[y]]}}], {r, 1, 
       Dimensions[radii][[1]]}, {y, 1, Dimensions[lensy][[1]]}],
     Table[
      Line[{{0, radii[[r]] + lensy[[y]]}, 
        10 {Cos[\[Theta]in[[r, y]] + radii[[r]]/
             f], -Sin[\[Theta]in[[r, y]] + radii[[r]]/f]} + {0, 
          radii[[r]] + lensy[[y]]}}], {r, 1, 
       Dimensions[radii][[1]]}, {y, 1, Dimensions[lensy][[1]]}]
     ,
     Gray, Table[Ellipsoid[{0, y}, {0.2, rlens}], {y, lensy}]
     }, PlotRange -> {{-10, 1.5 f}, {-(nlens/2)*rlens - 1, 
       nlens/2*rlens}}, Background -> Black]
   , {t, 0, 1, 0.1}];
ListAnimate[
 Join[frames1, Reverse@frames1, frames2, Reverse@frames2, frames3, Reverse@frames3, frames4, Reverse@frames4, frames5, 
  Reverse@frames5] ]

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Category:CC-Zero#Shack-Hartmann.gif
Category:Self-published work Category:Sensors Category:Optics Category:Animated GIF files Category:Images with Mathematica source code
Category:Animated GIF files Category:CC-Zero Category:Images with Mathematica source code Category:Optics Category:Self-published work Category:Sensors