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.

addSurface(obj)
function grid = addSurface(obj)
% addSurface - add surface roughness to a plane

% map to more convenient variables
a = obj.rotations;		% rotations with respect to the global frame of reference
Zz = obj.surface(3,:);	% a rough surface in reference position

% generate destination grid
if isempty(obj.xyJitter)
    [X Y] = generateMesh(obj);
else
    X = reshape(obj.referenceGrid(1,:), obj.nGrid(1),[]);
    Y = reshape(obj.referenceGrid(2,:), obj.nGrid(1),[]);
end

% prepare surface data
% check sizes, interpolate data if necessary
if (obj.nGrid(1) * obj.nGrid(2)) ~= size(obj.surface,2)
	displayMessage(2, [obj.name ' resample surface data']);
	
	% recover source grid
	X0 = reshape(obj.surface(1,:), obj.surfaceNGrid(1),[]);
	Y0 = reshape(obj.surface(2,:), obj.surfaceNGrid(1),[]);
	Z0 = reshape(obj.surface(3,:), obj.surfaceNGrid(1),[]);
	
	% resample data
	F = griddedInterpolant(X0, Y0, Z0);
	Zz = F(X,Y);
end

	% save memory
	clear x y X Y X0 Y0 Z0;

% assemble Z
Z = zeros(3,length(Zz));
Z(3,:) = Zz;

% rotate and translate
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];
           
grid = obj.grid + Rz*Ry*Rx*Z;

Contact us