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.

generateGridLocations(obj, displacement)
function [G G0]= generateGridLocations(obj, displacement)
% generate grid locations [xi; yi; 0] and rotate/translate the results in
% 3d space
%
% G ... grid, [xi; yi; zi] with 3 rows, (m*n) columns
% displacement ... move grid along the surface normal, out of the origin

% map to more convenient variables
r = obj.translations;	% displacement of the surface, with respect to the global origin
a = obj.rotations;		% rotations with respect to the global frame of reference

% if the grid is not in the objects x/y plane, e.g. for lenses
r = r + displacement * obj.normal;

% coordinate vectors
[X Y] = generateMesh(obj);

% grid points in reference position (no rotation or translation)
G0 = zeros(3,numel(X));
G0(1,:) = reshape(X, 1, []);
G0(2,:) = reshape(Y, 1, []);

	% save memory
	clear x y X Y;

% add jitter
if ~isempty(obj.xyJitter)
    displayMessage(3, [obj.name ': add x/y jitter']);
    G0(1,:) = G0(1,:) + obj.xyJitter(1) .* rand(1,numel(G0(1,:))) - obj.xyJitter(1)./2;
    G0(2,:) = G0(2,:) + obj.xyJitter(2) .* rand(1,numel(G0(2,:))) - obj.xyJitter(2)./2;
end

% angles
alpha = a(1);
beta  = a(2);
gamma = a(3);

Rx = [1          0           0;...
      0 cos(alpha) -sin(alpha);...
      0 sin(alpha)  cos(alpha)];
Ry = [ cos(beta) 0 sin(beta);...
               0 1         0;...
      -sin(beta) 0 cos(beta)];  
Rz = [cos(gamma) -sin(gamma) 0;...
      sin(gamma)  cos(gamma) 0;...
               0           0 1];
           
G = Rz*Ry*Rx * G0 + r(:,ones(1,size(G0,2)));

Contact us