## Copyright (C) 2017 Fabian Alexander Wilms ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your Value) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} viscircles (@var{centers}, @var{radii}) ## @deftypefn {Function File} viscircles (@var{ax}, @var{centers}, @var{radii}) ## @deftypefn {Function File} {@var{h} =} viscircles (@var{ax}, @var{centers}, @var{radii}) ## @deftypefn {Function File} {@var{h} =} viscircles (@var{___}, @var{name}, @var{value}) ## Draws circles with specified centers and radii on top of the current or given axes. ## ## The following additional properties can be specified, default in brackets: ## EnhanceVisibility (true) ## Color ('red') ## LineStyle ('-') ## LineWidth (2) ## Author: Fabian Alexander Wilms function h = viscircles(varargin) nVarargs = length(varargin); EnhanceVisibilityValue = true; ColorValue = 'red'; LineStyleValue = '-'; LineWidthValue = 2; try get(varargin{1},'type') ax = varargin{1}; centers = varargin{2}; radii = varargin{3}; catch ax = gca; centers = varargin{1}; radii = varargin{2}; end inputExist = find(cellfun(@(x) strcmpi(x, 'EnhanceVisibility') , varargin)); if inputExist EnhanceVisibilityValue = varargin{inputExist+1}; end inputExist = find(cellfun(@(x) strcmpi(x, 'Color') , varargin)); if inputExist ColorValue = varargin{inputExist+1}; end inputExist = find(cellfun(@(x) strcmpi(x, 'LineStyle') , varargin)); if inputExist LineStyleValue = varargin{inputExist+1}; end inputExist = find(cellfun(@(x) strcmpi(x, 'LineWidth') , varargin)); if inputExist LineWidthValue = varargin{inputExist+1}; end hold on alpha_samples = 0:2*pi/100:2*pi; for i=1:length(centers) x_samples = radii(i) * cos(alpha_samples) + centers(i,1); y_samples = radii(i) * sin(alpha_samples) + centers(i,2); if EnhanceVisibilityValue plot(ax, x_samples, y_samples, 'Color', 'white', 'LineStyle', '-', 'LineWidth', LineWidthValue+2); end plot(ax, x_samples, y_samples, 'Color', ColorValue, 'LineStyle', LineStyleValue, 'LineWidth', LineWidthValue); end hold off h = hggroup(); end