diff options
Diffstat (limited to 'misc/r2f/f2r.m')
-rw-r--r-- | misc/r2f/f2r.m | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/misc/r2f/f2r.m b/misc/r2f/f2r.m new file mode 100644 index 0000000..27b6e1c --- /dev/null +++ b/misc/r2f/f2r.m @@ -0,0 +1,130 @@ +%---------------------------------------------------------------------------
+% SYNTAX: R=f2r(f <,lenstype>)
+% <...> indicates optional arguments
+%
+%
+% Uses a lookup table or a formula to obtain the focal length of a
+% spherical lens for 1064 nm light from the radius of curvature.
+%
+%
+%
+% INTPUT ARGUMENTS:
+% f = focal length of the lens [mm]
+% lenstype = Defines the source to use for the conversion. Can be on of
+% the following:
+%
+% cvi_plcx_bk7 -- CVI corp. plano-convex, BK7 lenses
+% cvi_bicx_bk7 -- CVI corp. bi-convex, BK7 lenses
+% cvi_plcc_bk7 -- CVI corp. plano-concave, BK7 lenses
+% cvi_bicc_bk7 -- CVI corp. bi-concave, bK7 lenses
+% cvi_plcx_sio2 -- CVI corp. plano-convex, Fused Silica lenses
+% cvi_bicx_sio2 -- CVI corp. bi-convex, Fused Silica lenses
+% cvi_plcc_sio2 -- CVI corp. plano-concave, Fused Silica lenses
+% cvi_bicc_sio2 -- CVI corp. bi-concave, Fused Silica lenses
+% default -- uses the formula R=2f.
+%
+% OUTPUT ARGUMENTS:
+% R = radius of curvature [mm]
+%
+%---------------------------------------------------------------------------
+% SYNTAX: f=f2r(f <,lenstype>)
+%-------------------------------------------------------------------------------
+
+function R=f2r(f,varargin);
+
+if nargin>=2, lenstype=varargin{1}; else lenstype='default'; end
+
+switch lower(lenstype)
+ case 'default'
+ R=f/2;
+ case 'cvi_plcx_bk7'
+ rawdata=load('CVI_PLCX_bK7_r2f_index.txt');
+ [data(:,1),sortorder]=sort(rawdata(:,2)); % f now in 1st col, in ascending order
+ data(:,2)=rawdata(sortorder',1); % R in 2nd column
+ [posn,exactmatch]=pos(data(:,1),f);
+ f_found=data(posn,1);
+ R=data(posn,2);
+ if ~exactmatch
+ disp(['f is not found in the catalog table. Closest f is ',num2str(f_found),' mm.']);
+ end
+ disp(['f = ',num2str(f_found),' -> R = ',num2str(R),' mm.']);
+ case 'cvi_bicx_bk7'
+ rawdata=load('CVI_BICX_BK7_r2f_index.txt');
+ [data(:,1),sortorder]=sort(rawdata(:,2)); % f now in 1st col, in ascending order
+ data(:,2)=rawdata(sortorder',1); % R in 2nd column
+ [posn,exactmatch]=pos(data(:,1),f);
+ f_found=data(posn,1);
+ R=data(posn,2);
+ if ~exactmatch
+ disp(['f is not found in the catalog table. Closest f is ',num2str(f_found),' mm.']);
+ end
+ disp(['f = ',num2str(f_found),' -> R = ',num2str(R),' mm.']);
+ case 'cvi_plcc_bk7'
+ rawdata=load('CVI_PLCC_bK7_r2f_index.txt');
+ [data(:,1),sortorder]=sort(rawdata(:,2)); % f now in 1st col, in ascending order
+ data(:,2)=rawdata(sortorder',1); % R in 2nd column
+ [posn,exactmatch]=pos(data(:,1),f);
+ f_found=data(posn,1);
+ R=data(posn,2);
+ if ~exactmatch
+ disp(['f is not found in the catalog table. Closest f is ',num2str(f_found),' mm.']);
+ end
+ disp(['f = ',num2str(f_found),' -> R = ',num2str(R),' mm.']);
+ case 'cvi_bicc_bk7'
+ rawdata=load('CVI_BICC_BK7_r2f_index.txt');
+ [data(:,1),sortorder]=sort(rawdata(:,2)); % f now in 1st col, in ascending order
+ data(:,2)=rawdata(sortorder',1); % R in 2nd column
+ [posn,exactmatch]=pos(data(:,1),f);
+ f_found=data(posn,1);
+ R=data(posn,2);
+ if ~exactmatch
+ disp(['f is not found in the catalog table. Closest f is ',num2str(f_found),' mm.']);
+ end
+ disp(['f = ',num2str(f_found),' -> R = ',num2str(R),' mm.']);
+ case 'cvi_plcx_sio2'
+ rawdata=load('CVI_PLCX_SIO2_r2f_index.txt');
+ [data(:,1),sortorder]=sort(rawdata(:,2)); % f now in 1st col, in ascending order
+ data(:,2)=rawdata(sortorder',1); % R in 2nd column
+ [posn,exactmatch]=pos(data(:,1),f);
+ f_found=data(posn,1);
+ R=data(posn,2);
+ if ~exactmatch
+ disp(['f is not found in the catalog table. Closest f is ',num2str(f_found),' mm.']);
+ end
+ disp(['f = ',num2str(f_found),' -> R = ',num2str(R),' mm.']);
+ case 'cvi_bicx_sio2'
+ rawdata=load('CVI_BICX_SIO2_r2f_index.txt');
+ [data(:,1),sortorder]=sort(rawdata(:,2)); % f now in 1st col, in ascending order
+ data(:,2)=rawdata(sortorder',1); % R in 2nd column
+ [posn,exactmatch]=pos(data(:,1),f);
+ f_found=data(posn,1);
+ R=data(posn,2);
+ if ~exactmatch
+ disp(['f is not found in the catalog table. Closest f is ',num2str(f_found),' mm.']);
+ end
+ disp(['f = ',num2str(f_found),' -> R = ',num2str(R),' mm.']);
+ case 'cvi_plcc_sio2'
+ rawdata=load('CVI_PLCC_SIO2_r2f_index.txt');
+ [data(:,1),sortorder]=sort(rawdata(:,2)); % f now in 1st col, in ascending order
+ data(:,2)=rawdata(sortorder',1); % R in 2nd column
+ [posn,exactmatch]=pos(data(:,1),f);
+ f_found=data(posn,1);
+ R=data(posn,2);
+ if ~exactmatch
+ disp(['f is not found in the catalog table. Closest f is ',num2str(f_found),' mm.']);
+ end
+ disp(['f = ',num2str(f_found),' -> R = ',num2str(R),' mm.']);
+ case 'cvi_bicc_sio2'
+ rawdata=load('CVI_BICC_SIO2_r2f_index.txt');
+ [data(:,1),sortorder]=sort(rawdata(:,2)); % f now in 1st col, in ascending order
+ data(:,2)=rawdata(sortorder',1); % R in 2nd column
+ [posn,exactmatch]=pos(data(:,1),f);
+ f_found=data(posn,1);
+ R=data(posn,2);
+ if ~exactmatch
+ disp(['f is not found in the catalog table. Closest f is ',num2str(f_found),' mm.']);
+ end
+ otherwise
+ error('lenstype not recognized');
+ end
+end
\ No newline at end of file |