function pts = cv_sphere_pts(radius, step_x, step_y, step_z, dist_eps)
%
% cv_sphere_pts - generate sample points on a sphere
% Call: pts = cv_sphere_pts(radius,step_x,step_y,step_z,dist_eps);
% On input:
%     radius: radius of the sphere
%     step_x: distance between samples in x direction
%     step_y: distance between samples in y direction
%     step_z: distance between samples in z direction
%     dist_eps: within distance of surface to sample
% On output:
%     pts: matrix of sample points and normals (n by 6)
% Author:
%     Tom Henderson
%     7 January 2000
% Custom Functions Used:
%     none
% Method:
%     step through defined grid in x,y,z and keep points within dist_eps
% of sphere
% Testing:
% > s = cv_sphere_pts(1,0.5,0.5,0.5,0.05)
%
% s =
%
%    -1     0     0    -1     0     0
%     0    -1     0     0    -1     0
%     0     0    -1     0     0    -1
%     0     0     1     0     0     1
%     0     1     0     0     1     0
%     1     0     0     1     0     0
%

pts = [];
for x = -radius:step_x:radius
   for y = -radius:step_y:radius
      for z = -radius:step_z:radius
         d = sqrt(x^2 + y^2 + z^2);
         if abs(d-radius)<dist_eps
            pts = [pts ; x, y, z, x/d, y/d, z/d];
         end
      end
   end
end

         