Mercurial > hg > mauch-mirex-2010
annotate _FullBNT/KPMtools/draw_circle.m @ 9:4ea6619cb3f5 tip
removed log files
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:55:11 +0100 |
parents | b5b38998ef3b |
children |
rev | line source |
---|---|
matthiasm@8 | 1 function h = draw_circle(x, r, outline_color, fill_color) |
matthiasm@8 | 2 % draw filled circles at centers x with radii r. |
matthiasm@8 | 3 % x is a matrix of columns. r is a row vector. |
matthiasm@8 | 4 |
matthiasm@8 | 5 n = 40; % resolution |
matthiasm@8 | 6 radians = [0:(2*pi)/(n-1):2*pi]; |
matthiasm@8 | 7 unitC = [sin(radians); cos(radians)]; |
matthiasm@8 | 8 |
matthiasm@8 | 9 % extend r if necessary |
matthiasm@8 | 10 if length(r) < cols(x) |
matthiasm@8 | 11 r = [r repmat(r(length(r)), 1, cols(x)-length(r))]; |
matthiasm@8 | 12 end |
matthiasm@8 | 13 |
matthiasm@8 | 14 h = []; |
matthiasm@8 | 15 % hold is needed for fill() |
matthiasm@8 | 16 held = ishold; |
matthiasm@8 | 17 hold on |
matthiasm@8 | 18 for i=1:cols(x) |
matthiasm@8 | 19 y = unitC*r(i) + repmat(x(:, i), 1, n); |
matthiasm@8 | 20 if nargin < 4 |
matthiasm@8 | 21 h = [h line(y(1,:), y(2,:), 'Color', outline_color)]; |
matthiasm@8 | 22 else |
matthiasm@8 | 23 h = [h fill(y(1,:), y(2,:), fill_color, 'EdgeColor', outline_color)]; |
matthiasm@8 | 24 end |
matthiasm@8 | 25 end |
matthiasm@8 | 26 if ~held |
matthiasm@8 | 27 hold off |
matthiasm@8 | 28 end |