X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=src%2FTests_hough%2Fdraw_ellipses.m;fp=src%2FTests_hough%2Fdraw_ellipses.m;h=d793f4d14edf39bc388e5ee45c5048317a44c1a0;hb=0ff8fb82457bd5a858b2218ab07f69c81323537e;hp=0000000000000000000000000000000000000000;hpb=c6fe9d606eff98fc73b75f23e02a9fd436458ed0;p=master-thesis.git diff --git a/src/Tests_hough/draw_ellipses.m b/src/Tests_hough/draw_ellipses.m new file mode 100644 index 0000000..d793f4d --- /dev/null +++ b/src/Tests_hough/draw_ellipses.m @@ -0,0 +1,44 @@ +% center : [x y] +function draw_ellipses(axe, ellipses, plot_3d, plot_center) + if ~exist('plot_3d', 'var') + plot_3d = false; + end + + if ~exist('plot_center', 'var') + plot_center = false; + end + + hold on; + + if plot_3d + z_space = [0 1]; + else + z_space = [0]; + end + + for i = 1:length(ellipses) + e = ellipses{i}; + transform_mat = [cos(e.alpha) -sin(e.alpha); sin(e.alpha) cos(e.alpha)]; + + p_previous = []; + for phi = linspace(0, 2 * pi, 36); + for z = z_space + p = [e.x0; e.y0] + transform_mat * [e.r1 * cos(phi); e.r2 * sin(phi)]; % p : [x y] + if ~isempty(p_previous) + line = plot3(axe, [p(1) p_previous(1)], [p(2) p_previous(2)], [z z], 'LineWidth', 1, 'Color', 'yellow'); + line.Color(4) = 0.5; + end + if z == 1 + line = plot3(axe, [p(1) p(1)], [p(2) p(2)], [0 1], 'LineWidth', 0.5, 'Color', 'yellow'); + line.Color(4) = 0.5; + end + end + p_previous = p; + end + + if plot_center + plot(e.x0, e.y0, 'r.', 'MarkerSize', 20); + end + end +end +