Code covered by the BSD License  

Highlights from
Optical_bench

image thumbnail
from Optical_bench by Bjorn Gustavsson
Optical_bench - a simple ray-tracing tool for optical systems.

Description of opt_grid

opt_grid

PURPOSE ^

OPT_GRID - Simple difractive grating

SYNOPSIS ^

function [opt1] = opt_grid(opt_type,opt_args)

DESCRIPTION ^

 OPT_GRID - Simple difractive grating
 OPT_TYPE should be 'grid' (hm good and vital argument), OPT_SPEC
 should be a string matrix, see README_OPT for specification.
   Necessary specification fields: 
 r1, dxdydx, linespmm,
 glass should be name of the glass type, the other 1x3 array
   Optional specification fields:
 normal, e_slit,
 example OPT_SPEC:
 'r1          12 0 0'
 'dxdydz      0 2 1'
 'linespmm    600'
 'normal      cos(10*pi/180) sin(10*pi/180) 0'
 
 Calling:
 [opt1] = opt_grid(opt_type,opt_args)
 
 See also OPT_APERTURE, OPT_SCREEN, OPT_LENS, OPT_PRISM, OPT_SLIT

CROSS-REFERENCE INFORMATION ^

This function calls:
  • opt_elem OPT_ELEM - Default opt_elem structure
  • opt_findstr OPT_FINDSTR - find string S in character array H,
  • opt_grid OPT_GRID - Simple difractive grating
This function is called by:
  • opt_build OPT_BUILD - Builds optical system specified in FILE
  • opt_grid OPT_GRID - Simple difractive grating

SOURCE CODE ^

0001 function [opt1] = opt_grid(opt_type,opt_args)
0002 % OPT_GRID - Simple difractive grating
0003 % OPT_TYPE should be 'grid' (hm good and vital argument), OPT_SPEC
0004 % should be a string matrix, see README_OPT for specification.
0005 %   Necessary specification fields:
0006 % r1, dxdydx, linespmm,
0007 % glass should be name of the glass type, the other 1x3 array
0008 %   Optional specification fields:
0009 % normal, e_slit,
0010 % example OPT_SPEC:
0011 % 'r1          12 0 0'
0012 % 'dxdydz      0 2 1'
0013 % 'linespmm    600'
0014 % 'normal      cos(10*pi/180) sin(10*pi/180) 0'
0015 %
0016 % Calling:
0017 % [opt1] = opt_grid(opt_type,opt_args)
0018 %
0019 % See also OPT_APERTURE, OPT_SCREEN, OPT_LENS, OPT_PRISM, OPT_SLIT
0020 
0021 % Version: 1.0
0022 % Copyright: Bjorn Gustavsson 20020430
0023 
0024 
0025 if nargin ~= 2,
0026   help opt_grid;
0027   ok = 0;
0028   return;
0029 end;
0030 
0031 opt1 = opt_elem(opt_type);
0032 opt1.glass = 'air'; %
0033 
0034 % defaults
0035 opt1.r(2:3) = 0; % Grid centered on the optical axis
0036 opt1.n = [1 0 0]; % Grid paralell with the optical axis
0037 opt1.e_slits = [0 0 1]; % Grid slits paralell with e_z
0038 
0039 % set the necessary ones:
0040 % grid size
0041 ii = opt_findstr(opt_args,'dydz');
0042 opt1.dxdydz = str2num(opt_args(ii,12:end));
0043 % grid position
0044 ii = opt_findstr(opt_args,'r1');
0045 opt1.r = str2num(opt_args(ii,12:end));
0046 % lines per mm
0047 ii = opt_findstr(opt_args,'linespmm');
0048 opt1.lpmm = str2num(opt_args(ii,12:end));
0049 
0050 % set the optional ones
0051 ii = opt_findstr(opt_args,'normal');
0052 if length(ii) == 1
0053   
0054   opt1.n = str2num(opt_args(ii(1),12:end));
0055   
0056 end
0057 
0058 ii = opt_findstr(opt_args,'e_slit');
0059 if length(ii) == 1
0060   
0061   opt1.e_slits = str2num(opt_args(ii(1),12:end));
0062   
0063 end

Generated on Thu 29-Apr-2010 14:16:49 by B. Gustavsson with m2html © 2003

Contact us