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_project_direction

opt_project_direction

PURPOSE ^

OPT_PROJECT_POINT - Project light from direction E with intensity I throug OPT_EL

SYNOPSIS ^

function opt_el = opt_project_direction(e,I,wavelengths,opt_el,opt_ops)

DESCRIPTION ^

 OPT_PROJECT_POINT - Project light from direction E with intensity I throug OPT_EL 
   
 Calling:
  opt_el = opt_project_direction(e,I,wavelengths,opt_el,opt_ops)
 
 Input:
   E - Direction [3x1] array.
   I - light intensities [Nx1] array
   WAVELENGTHS - light wavelength (nm)(m)
   OPT_EL - optical system [Mx1] array of opt_elem
   OPT_OPS - struct with options, see OPT_TYPICAL_OPS

CROSS-REFERENCE INFORMATION ^

This function calls:
  • opt_ray OPT_RAY - RAY creator for OPT_TOOLS
  • opt_trace OPT_TRACE - ray tracing through optical systems.
This function is called by:

SOURCE CODE ^

0001 function opt_el = opt_project_direction(e,I,wavelengths,opt_el,opt_ops)
0002 % OPT_PROJECT_POINT - Project light from direction E with intensity I throug OPT_EL
0003 %
0004 % Calling:
0005 %  opt_el = opt_project_direction(e,I,wavelengths,opt_el,opt_ops)
0006 %
0007 % Input:
0008 %   E - Direction [3x1] array.
0009 %   I - light intensities [Nx1] array
0010 %   WAVELENGTHS - light wavelength (nm)(m)
0011 %   OPT_EL - optical system [Mx1] array of opt_elem
0012 %   OPT_OPS - struct with options, see OPT_TYPICAL_OPS
0013 
0014 if length(opt_el(1).diameter)
0015   dl = -opt_el(1).diameter/2:opt_el(1).diameter/60:opt_el(1).diameter/2;
0016 else
0017   dl = -max(opt_el(1).dxdydz)/2:max(opt_el(1).dxdydz)/60:max(opt_el(1).dxdydz)/2;
0018 end
0019 
0020 if isfield(opt_ops,'test')
0021   dl = linspace(min(dl),max(dl),opt_ops.test);
0022 end  
0023 n = opt_el(1).n;
0024 ey = [0 1 0];
0025 rc = opt_el(1).r;
0026 
0027 if dot(n,ey)>1-100*eps
0028   e1 = cross(n,ey);
0029   e1 = e1/norm(e1);
0030   e2 = cross(n,e1);
0031 else
0032   e1 = cross(n,[0 0 1]);
0033   e1 = e1/norm(e1);
0034   e2 = cross(n,e1);
0035 end
0036 
0037 x1 = nan*zeros([length(dl) length(dl)]);
0038 y1 = x1;
0039 z1 = x1;
0040 
0041 for li1 =1:length(dl),
0042   for li2 = 1:length(dl),
0043     rinter = rc + e1*dl(li1) + e2*dl(li2);
0044     x1(li2,li1) = rinter(1);
0045     y1(li2,li1) = rinter(2);
0046     z1(li2,li1) = rinter(3);
0047   end
0048 end
0049 
0050 
0051 ray = opt_ray;
0052 
0053 rays(1:size(x1,1),1:size(x1,2)) = ray;
0054 
0055 for ii = 1:size(x1,2),
0056   
0057   for j = 1:size(x1,1),
0058     
0059     rays(j,ii).r = [x1(j,ii) y1(j,ii) z1(j,ii)];
0060     rays(j,ii).e = e/norm(e);
0061     
0062   end
0063 end
0064 
0065 for ij = 1:length(I),
0066   
0067   for ii = 1:size(x1,2),
0068     
0069     for jj = 1:size(x1,1),
0070       
0071       rays(jj,ii).I = I(ij);
0072       rays(jj,ii).wavelength = wavelengths(ij);
0073       
0074     end
0075   end
0076   
0077   [opt_el] = opt_trace(opt_el,rays(:),opt_ops);
0078   
0079 end

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

Contact us