summaryrefslogtreecommitdiff
path: root/misc/r2f/f2r.m
blob: 27b6e1cf1e151df3f464719861d61ec9e9ad5595 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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