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.

checkBasics(obj)
function obj = checkBasics(obj)
% checkBasics - check for basic inputs like the surface normal, the normal
% distance, translations and rotations

% check for surface normal
if isempty(obj.normal)					% there is none
	if ~isempty(obj.rotations)
		displayMessage(2, [obj.name ': surface normal']);
		obj.normal = surfaceNormal(obj.rotations);
	else		
		displayMessage(-1, [obj.name ': ERROR miss ''rotations'' parameter']);
	end
else									% there is one, but ...
	if size(obj.normal,1) ~= 3			% is it a column vector?
		obj.normal = obj.normal.';
	end
end

% get object rotations
if isempty(obj.rotations)
	displayMessage(1, [obj.name ': rotations']);
	p = obj.normal;
	obj.rotations = [atan2(p(3),p(2)) atan2(p(3),p(1)) atan2(p(2),p(1))];
end

% check if obj.translations is a column vector
if ~isempty(obj.translations) && size(obj.translations,1) ~= 3
	obj.translations = obj.translations.';
end

% compute translations or the normal distance to the global origin
if isempty(obj.translations) && ~isempty(obj.normalDistance)
	% translation along the surface normal
	displayMessage(2, [obj.name ': translations']);
	obj.translations = -obj.normalDistance * obj.normal;	
elseif ~isempty(obj.translations) && isempty(obj.normalDistance)
	% shortest distance to the global origin
	displayMessage(2, [obj.name ': normal distance']);
	obj.normalDistance = abs(obj.translations' * obj.normal)/(sqrt(obj.normal'*obj.normal));	
else
	% prefer the simple case and recompute the displacement
	displayMessage(2, [obj.name ': translations']);
	obj.translations = -obj.normalDistance * obj.normal;
	displayMessage(0,[obj.name ': WARNING overwrite existing ''translations'' parameter']);
end

% rotate the coordinate system
if isempty(obj.coordinateSystem)
	displayMessage(2, [obj.name ': coordinate system']);
	obj.coordinateSystem = rotatePoints(eye(3), obj.rotations);
end

Contact us