Code covered by the BSD License  

Highlights from
Huygens-Fresnel integral approximation, free-form apertures and rough surfaces

image thumbnail

Huygens-Fresnel integral approximation, free-form apertures and rough surfaces

by

 

Simulate wave propagation through free-form apertures, or off rough surfaces.

plotIllumination(obj, nGrid, useLog)
function h = plotIllumination(obj, nGrid, useLog)
% plotIllumination - plot intensity
%
% h ........ figure handle
% obj ...... object to draw
% nGrid .... interpolate surface anew at [N M] points
% useLog ... use a logarithmic scale

% get grid coordinates and E-field values
[X Y] = generateMesh(obj);
E = reshape(obj.E, obj.nGrid(1),[]);

x = X(:,1);
y = Y(1,:);

% interpolate surface anew
if ~isempty(nGrid)
	if isnumeric(nGrid) && numel(nGrid) == 2
		% map to more convenient variables
		s = obj.resolution;				% spatial resolution [dx dy]
		m = obj.nGrid;					% number of points [m n]
		d = obj.size ./ (nGrid - 1);	% new interval
		
		% rectangular coordinate vectors
		x = -s(1) * m(1)/2 : d(1) : s(1) * m(1)/2-1;
		y = -s(2) * m(2)/2 : d(2) : s(2) * m(2)/2-1;

		% new mesh
		[XI YI] = ndgrid(x, y);
		
		% interpolate image data at new positions
		F = griddedInterpolant(X,Y,E);
		E = F(XI, YI);
	end
end

% image is proportional to intensity
I = E.*conj(E);

% show the results
if isfield(obj, 'saturation') && ~isempty(obj.saturation)
	I = obj.saturation(I);	
end

h = figure;
if useLog
	imagesc(x, y, log(I));
else
	imagesc(x, y, I);
end
axis equal tight;
xlabel('y');
ylabel('x');
colorbar;

Contact us