function displaySpheres(centers, radiuses, alpha)
%DISPLAYSPHERES  Display 3D spheres.
%   DISPLAYSPHERES(CENTERS, RADIUSES, ALPHA) displays spheres of given
%   centers (Nx3 matrix) and radiuses (1xN vector) with the (optional)
%   given transparency (alpha value).

%   Author: Damien Teney

if nargin < 3 % Missing argument
  alpha = 0.4; % Set default value
end

% Constants
resolution = 16;
color = 0.5 * [1 1 1];

for i = 1:size(centers, 1)
  center = centers(i, :);
  radius = radiuses(i);

  % Plot a sphere
  [x y z] = sphere(resolution);
  surf(center(1) + x * radius, ...
       center(2) + y * radius, ...
       center(3) + z * radius, ...
       'FaceColor', color, ...
       'LineStyle', 'none', ...
       'FaceAlpha', alpha);
       %'EdgeColor', 'k', ...
       %'EdgeAlpha', 0.1, ...
       %'FaceLighting','phong', ...
end

% Enable the shading
%camlight left;
