Optical Layout Example -- Periscope

Contents

Basic Example

% Use "sub-shapes" to specify parameters for the launch,
% the lenses, and the mirrors.  Do not draw anything yet.
% Launch.
LAUNCH   = davinci( 'optical_layout.beam_launch',  'Position',           [0 0], ...
                                                   'Direction',          [1 0], ...
                                                   'BeamWidth',              4, ...
                                                   'BeamLineWidth',          2 );
% Lenses.
L1       = davinci( 'optical_layout.lens',         'LineWidth',              2, ...
                                                   'DistanceToFocus',        6, ...
                                                   'Height',                 8 );
L2       = davinci( 'optical_layout.lens',         'LineWidth',              2, ...
                                                   'Height',                 8 );  % This is a field lens, so 'Height' must be specified.
L3       = davinci( 'optical_layout.lens',         'DistanceToFocus',      Inf, ...
                                                   'LineWidth',              2, ...
                                                   'Height',                 8 );
L4       = davinci( 'optical_layout.lens',         'DistanceToFocus',       12, ...
                                                   'LineWidth',              2, ...
                                                   'Height',                 8 );
L5       = davinci( 'optical_layout.lens',         'DistanceToFocus',        4, ...
                                                   'LineWidth',              2, ...
                                                   'Height',                 8 );
L6       = davinci( 'optical_layout.lens',         'DrawFlag',           false );   % Dummy lens helps us fill in beam with patch objects.
L7       = L3;
% Mirrors.
M1       = davinci( 'optical_layout.mirror',       'LineOrRectangle', 'rectangle' );
M2       = M1;
% Assemble the system.  Use the ">" operator to merge the
% "sub-shape" parameters with the travel distances.  Use the "/"
% operator to tilt the mirrors.  Do not draw anything yet.
LAYOUT = LAUNCH > 9 > (M1/45) > 6 > L1 > 6 > L2 > 5 > L3 ...
                > 17 > L4 > 6 > L5 > 4 > L6 > 3.5 > (M2/-45) > 6 > L7 > 6;
% Draw the layout.
h = davinci( 'optical_layout', 'Layout', LAYOUT );
daspect([1 1 1])   % Set aspect ratio to 1:1.
% For readability.
e1x = [ h.edge_ray_1.XData ];
e1y = [ h.edge_ray_1.YData ];
e2x = [ h.edge_ray_2.XData ];
e2y = [ h.edge_ray_2.YData ];
% Fill in beam as patch objects.  This must be done manually.
patch( [e1x(1) e1x(2) e2x(2) e2x(1)], ...
       [e1y(1) e1y(2) e2y(2) e2y(1)], 'b', 'FaceAlpha', .4 );
patch( [e1x(3) e1x(4) e1x(5) e1x(6) e2x(6) e2x(5) e2x(4) e2x(3)], ...
       [e1y(3) e1y(4) e1y(5) e1y(6) e2y(6) e2y(5) e2y(4) e2y(3)], 'b', 'FaceAlpha', .4 );
patch( [e1x(7) e1x(8) e1x(9) e1x(10) e1x(11) e1x(12) e1x(13) e1x(14) e2x(14) e2x(13) e2x(12) e2x(11) e2x(10) e2x(9) e2x(8) e2x(7)], ...
       [e1y(7) e1y(8) e1y(9) e1y(10) e1y(11) e1y(12) e1y(13) e1y(14) e2y(14) e2y(13) e2y(12) e2y(11) e2y(10) e2y(9) e2y(8) e2y(7)], 'b', 'FaceAlpha', .4 );
patch( [e1x(15) e1x(16) e2x(16) e2x(15)], ...
       [e1y(15) e1y(16) e2y(16) e2y(15)], 'b', 'FaceAlpha', .4 );
patch( [e1x(17) e1x(18) e1x(19) e1x(20) e2x(20) e2x(19) e2x(18) e2x(17)], ...
       [e1y(17) e1y(18) e1y(19) e1y(20) e2y(20) e2y(19) e2y(18) e2y(17)], 'b', 'FaceAlpha', .4 );