0001 % Example of spherical aberation
0002
0003 % Set the options for ploting of the optics/raytracing
0004 opt_ops.plotrays=1; % plot the individual rays
0005 opt_ops.plotpaus=0; % do not pause after each ray intersection
0006 opt_ops.plotRT = 0; % do not ``drawnow'' after each ray intersection
0007
0008 % build the optical system as specified in opt.exmpl
0009 optelements = opt_build('opt_single_lens2.exmpl');
0010
0011 % make a default ray
0012 ray = opt_ray;
0013
0014 %make 100 paralell rays with random displacement in y-z plane
0015 nr_rays = 18;
0016
0017 clrs = jet(9);
0018
0019 for ray_i = 2:nr_rays,
0020
0021 fi_of_i = atan(2/20-ray_i/100);
0022
0023 rays(ray_i) = ray;
0024 rays(ray_i).r = [-20 0 2-4*ray_i/20];
0025 %rays(ray_i).e = [cos(fi_of_i) 0 sin(fi_of_i)];
0026 rays(ray_i).e = [1 0 0];
0027 rays(ray_i).color = clrs(abs(ray_i-10)+1,:); % color is line color for
0028 % plotting of rays
0029
0030 end
0031
0032 %subplot(2,2,1)
0033 % plot the optical system
0034 opt_plotoptics(optelements);
0035 hold on
0036 % trace all rays
0037 [opt_screen] = opt_trace(optelements,rays,opt_ops);
0038 view(0,90)
0039
0040 % $$$ subplot(2,2,2)
0041 % $$$ % Last element should be a screen, which stores the image.
0042 % $$$ imagesc(opt_screen(end).img)
0043 % $$$ axis([245 265 245 265])
0044 % $$$
0045 % $$$ subplot(2,2,3)
0046 % $$$ ray.r = [-3 -1 0];
0047 % $$$ opt_plotoptics(optelements);
0048 % $$$ hold on
0049 % $$$ [opt_screen] = opt_trace(optelements,ray,opt_ops);
0050 % $$$ view(-15,75)