summaryrefslogtreecommitdiff
path: root/misc/r2f/r2f.m
blob: 8d6fcdf5a97b10dc43b7e5b7ede98cf771764698 (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:  f=r2f(R <,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:
% R        = radius of curvature [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:
% f        = focal length of the lens [mm]
%
%---------------------------------------------------------------------------
% SYNTAX:  f=r2f(R <,lenstype>)
%-------------------------------------------------------------------------------

function f=r2f(R,varargin);

if nargin>=2, lenstype=varargin{1}; else lenstype='default'; end

switch lower(lenstype)
    case 'default'
        f=2*R;
    case 'cvi_plcx_bk7'
        rawdata=load('CVI_PLCX_bK7_r2f_index.txt');
        [data(:,1),sortorder]=sort(rawdata(:,1));   % R now in 1st col, in ascending order
        data(:,2)=rawdata(sortorder',2);            % f in 2nd column
        [posn,exactmatch]=pos(data(:,1),R);
        Rfound=data(posn,1);
        f=data(posn,2);
        if ~exactmatch
            disp(['R is not found in the catalog table.  Closest R is ',num2str(Rfound),' mm.']); 
        end
        disp(['R = ',num2str(Rfound),' -> R = ',num2str(f),' mm.']);
    case 'cvi_bicx_bk7'
        rawdata=load('CVI_BICX_BK7_r2f_index.txt');
        [data(:,1),sortorder]=sort(rawdata(:,1));   % R now in 1st col, in ascending order
        data(:,2)=rawdata(sortorder',2);            % f in 2nd column
        [posn,exactmatch]=pos(data(:,1),R);
        Rfound=data(posn,1);
        f=data(posn,2);
        if ~exactmatch
            disp(['R is not found in the catalog table.  Closest R is ',num2str(Rfound),' mm.']); 
        end        
        disp(['R = ',num2str(Rfound),' -> R = ',num2str(f),' mm.']);
    case 'cvi_plcc_bk7'
        rawdata=load('CVI_PLCC_bK7_r2f_index.txt');
        [data(:,1),sortorder]=sort(rawdata(:,1));   % R now in 1st col, in ascending order
        data(:,2)=rawdata(sortorder',2);            % f in 2nd column
        [posn,exactmatch]=pos(data(:,1),R);
        Rfound=data(posn,1);
        f=data(posn,2);
        if ~exactmatch
            disp(['R is not found in the catalog table.  Closest R is ',num2str(Rfound),' mm.']); 
        end
        disp(['R = ',num2str(Rfound),' -> R = ',num2str(f),' mm.']);
    case 'cvi_bicc_bk7'
        rawdata=load('CVI_BICC_BK7_r2f_index.txt');
        [data(:,1),sortorder]=sort(rawdata(:,1));   % R now in 1st col, in ascending order
        data(:,2)=rawdata(sortorder',2);            % f in 2nd column
        [posn,exactmatch]=pos(data(:,1),R);
        Rfound=data(posn,1);
        f=data(posn,2);
        if ~exactmatch
           disp(['R is not found in the catalog table.  Closest R is ',num2str(Rfound),' mm.']); 
        end          
        disp(['R = ',num2str(Rfound),' -> R = ',num2str(f),' mm.']);
    case 'cvi_plcx_sio2'
        rawdata=load('CVI_PLCX_SIO2_r2f_index.txt');
        [data(:,1),sortorder]=sort(rawdata(:,1));   % R now in 1st col, in ascending order
        data(:,2)=rawdata(sortorder',2);            % f in 2nd column
        [posn,exactmatch]=pos(data(:,1),R);
        Rfound=data(posn,1);
        f=data(posn,2);
        if ~exactmatch
            disp(['R is not found in the catalog table.  Closest R is ',num2str(Rfound),' mm.']); 
        end
        disp(['R = ',num2str(Rfound),' -> R = ',num2str(f),' mm.']);
    case 'cvi_bicx_sio2'
        rawdata=load('CVI_BICX_SIO2_r2f_index.txt');
        [data(:,1),sortorder]=sort(rawdata(:,1));   % R now in 1st col, in ascending order
        data(:,2)=rawdata(sortorder',2);            % f in 2nd column
        [posn,exactmatch]=pos(data(:,1),R);
        Rfound=data(posn,1);
        f=data(posn,2);
        if ~exactmatch
            disp(['R is not found in the catalog table.  Closest R is ',num2str(Rfound),' mm.']); 
        end        
        disp(['R = ',num2str(Rfound),' -> R = ',num2str(f),' mm.']);
    case 'cvi_plcc_sio2'
        rawdata=load('CVI_PLCC_SIO2_r2f_index.txt');
        [data(:,1),sortorder]=sort(rawdata(:,1));   % R now in 1st col, in ascending order
        data(:,2)=rawdata(sortorder',2);            % f in 2nd column
        [posn,exactmatch]=pos(data(:,1),R);
        Rfound=data(posn,1);
        f=data(posn,2);
        if ~exactmatch
            disp(['R is not found in the catalog table.  Closest R is ',num2str(Rfound),' mm.']); 
        end
        disp(['R = ',num2str(Rfound),' -> R = ',num2str(f),' mm.']);
    case 'cvi_bicc_sio2'
        rawdata=load('CVI_BICC_SIO2_r2f_index.txt');
        [data(:,1),sortorder]=sort(rawdata(:,1));   % R now in 1st col, in ascending order
        data(:,2)=rawdata(sortorder',2);            % f in 2nd column
        [posn,exactmatch]=pos(data(:,1),R);
        Rfound=data(posn,1);
        f=data(posn,2);
        if ~exactmatch
           disp(['R is not found in the catalog table.  Closest R is ',num2str(Rfound),' mm.']); 
        end          
    otherwise
        error('lenstype not recognized');
    end
end