function pts = cv_circle_pts(radius, step_x, step_y)
%
% cv_circle_pts - generate sample points/normals on a circle
% Call: pts = cv_circle_pts(radius,step_x,step_y);
% On input:
%     radius: radius of circle in plane
%     step_x: distance in x between samples
%     step_y: distance in y between samples
% On output:
%     pts: n by 6 matrix of points (x,y,z,a,b,c)
% Author:
%     Tom Henderson
%     7 January 1999
% Custom Functions Used:
%     none
% Method:
%     Generate all points in rectangle defined by x range (-radius,radius) 
% and y range (-radius,radius) about origin and keep points within radius
% distance of origin.  The normal vector is in z-axis direction.
% Testing:
% > pts = cv_circle_pts(1,1,1)
%
% pts =
%
%    -1     0     0     0     0     1
%     0    -1     0     0     0     1
%     0     0     0     0     0     1
%     0     1     0     0     0     1
%     1     0     0     0     0     1
%     
r2 = radius^2;     % Use radius squared -- it's cheaper than sqrt
x_vals = -radius:step_x:radius;     % x domain
y_vals = -radius:step_y:radius;     % y domain
x_len = length(x_vals);    % spread in x
y_len = length(y_vals);    % spread in y
pts_index = 0;
pts = zeros(x_len*y_len,6);  % set up pts array
pts(:,6) = 1;    % set normal in z direction
for x_index = 1:x_len
   x = x_vals(x_index);
   for y_index = 1:y_len
      y = y_vals(y_index);
      if (x^2 + y^2) <= r2    % compare squared distances
         pts_index = pts_index + 1;   % insert point
         pts(pts_index,1) = x;
         pts(pts_index,2) = y;
      end
   end
end
pts = pts(1:pts_index,:);  % reset to exact set of points
