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.

plotCrossSections(obj, x0, y0)
function [h1 h2] = plotCrossSections(obj, x0, y0)
% plotCrossSections - plot x- and y- slices of image data
%
% x0 ... fixed x-coordinate, plot all available y-coordinates
% y0 ... fixed y-coordinate, plot all available x-coordinates

% map to more convenient variables
s = obj.resolution;		% spatial resolution [dx dy]
m = obj.nGrid;			% number of points [m n]

% image coordinates and coordinate vectors
% disregard rotations/translations
X = reshape(obj.surface(1,:), m(1),[]);
Y = reshape(obj.surface(2,:), m(1),[]);
x = X(:,1);
y = Y(1,:);

% check ranges
if x0 < min(x(:)) || x0 > max(x(:))
	disp(['x0 out of range [' num2str(min(x(:))) ':' num2str(max(x(:))) ']']);
	return;
end
if y0 < min(y(:)) || y0 > max(y(:))
	disp(['y0 out of range [' num2str(min(y(:))) ':' num2str(max(y(:))) ']']);
	return;
end

% image data (prop to intensity)
C = reshape(obj.E, m(1),[]).*(s(1)*s(2));
C = C.*conj(C);

% interpolate image data at position
F = griddedInterpolant(X,Y,C);
Cx = F(x0 * ones(1,m(1)), y);
Cy = F(x,y0 * ones(m(2),1));

% plot results
h1 = figure();
imagesc(x,y,C);
xlabel('y');
ylabel('x');

h2 = figure();
plot(y, Cx, x, Cy);
title(['x0 = ' num2str(x0) ', y0 = ' num2str(y0)]);
xlabel('x/y');
legend(['x0 = ' num2str(x0) ', y'], ['x, y0 = ' num2str(y0)]);
grid on;

Contact us