Add some tests on different variations of Hough algorithm.
[master-thesis.git] / src / Tests_hough / draw_ellipses.m
1 % center : [x y]
2 function draw_ellipses(axe, ellipses, plot_3d, plot_center)
3     if ~exist('plot_3d', 'var')
4         plot_3d = false;
5     end
6     
7     if ~exist('plot_center', 'var')
8         plot_center = false;
9     end
10
11     hold on;
12     
13     if plot_3d
14         z_space = [0 1];
15     else
16         z_space = [0];
17     end
18     
19     for i = 1:length(ellipses)
20         e = ellipses{i};
21         transform_mat = [cos(e.alpha) -sin(e.alpha); sin(e.alpha) cos(e.alpha)]; 
22
23         p_previous = [];
24         for phi = linspace(0, 2 * pi, 36);
25            for z = z_space
26                 p = [e.x0; e.y0] + transform_mat * [e.r1 * cos(phi); e.r2 * sin(phi)]; % p : [x y]
27                 if ~isempty(p_previous)
28                     line = plot3(axe, [p(1) p_previous(1)], [p(2) p_previous(2)], [z z], 'LineWidth', 1, 'Color', 'yellow');
29                     line.Color(4) = 0.5;
30                 end
31                 if z == 1
32                    line = plot3(axe, [p(1) p(1)], [p(2) p(2)], [0 1], 'LineWidth', 0.5, 'Color', 'yellow'); 
33                    line.Color(4) = 0.5;
34                 end
35            end
36            p_previous = p;
37         end
38         
39         if plot_center
40             plot(e.x0, e.y0, 'r.', 'MarkerSize', 20);
41         end
42     end
43 end
44