function [h, x, y] = circle(center, radius, n_points, varargin)
%---------------------------------------------------------------------------------------------
% h = circle(center, radius, n_points, style)
% This routine draws a circle with center defined as
% a vector `center`, radius as a scaler `radius`. `n_points` is
% the number of points on the circle. As to `style`,
% use it the same way as you use the rountine `plot`.
% Since the handle of the object is returned, you
% use routine `set` to get the best result.
%
%   Usage Examples,
%
%   circle([1,3], 3, 1000, ':');
%   circle([2,4], 2, 1000, '--');
%
%   Zhenhai Wang <zhenhai@ieee.org>
%   Maximilian Schütte <maximilian.schuette@desy.de>
%   Version 1.1
%   September, 2021
%---------------------------------------------------------------------------------------------

    if (nargin < 3)
        error('Please see help for INPUT DATA.');
    elseif (nargin == 3)
        varargin = {'b-'};
    end

    theta = linspace(0, 2*pi, n_points);
    rho = ones(1, n_points) * radius;
    [x, y] = pol2cart(theta, rho);
    x = x + center(1);
    y = y + center(2);

    h = plot(x, y, varargin{:});

end