[37] | 1 | % DRAWSEG - Draws a series of line segments stored in an Nx4 array. |
---|
| 2 | % |
---|
| 3 | % Usage: drawseg(seglist, figNo, lw, col, marker); |
---|
| 4 | % |
---|
| 5 | % seglist - an Nx4 array storing line segments in the form |
---|
| 6 | % [x1 y1 x2 y2 |
---|
| 7 | % x1 y1 x2 y2 |
---|
| 8 | % . . ] etc |
---|
| 9 | % figNo - optional figure number |
---|
| 10 | % lw - optional line width |
---|
| 11 | % col - optional 3-vector specifying the colour |
---|
| 12 | % marker - optional character specifying a marker to be plotted at |
---|
| 13 | % the end of each segment, eg '*' |
---|
| 14 | % |
---|
| 15 | % |
---|
| 16 | % See also: EDGELINK, LINESEG, MAXLINEDEV, MERGESEG |
---|
| 17 | % |
---|
| 18 | |
---|
| 19 | % Copyright (c) 2000-2005 Peter Kovesi |
---|
| 20 | % School of Computer Science & Software Engineering |
---|
| 21 | % The University of Western Australia |
---|
| 22 | % http://www.csse.uwa.edu.au/ |
---|
| 23 | % |
---|
| 24 | % Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 25 | % of this software and associated documentation files (the "Software"), to deal |
---|
| 26 | % in the Software without restriction, subject to the following conditions: |
---|
| 27 | % |
---|
| 28 | % The above copyright notice and this permission notice shall be included in |
---|
| 29 | % all copies or substantial portions of the Software. |
---|
| 30 | % |
---|
| 31 | % The Software is provided "as is", without warranty of any kind. |
---|
| 32 | |
---|
| 33 | % December 2000 Original version |
---|
| 34 | % August 2006 Added option to specify marker plotted at end points |
---|
| 35 | |
---|
| 36 | function drawseg(seglist, figNo, lw, col, marker); |
---|
| 37 | |
---|
| 38 | if nargin >= 2 |
---|
| 39 | figure(figNo); |
---|
| 40 | end |
---|
| 41 | |
---|
| 42 | if nargin < 3 |
---|
| 43 | lw = 1; |
---|
| 44 | col = [0 0 1]; |
---|
| 45 | elseif nargin < 4 |
---|
| 46 | col = [0 0 1]; |
---|
| 47 | end |
---|
| 48 | |
---|
| 49 | if nargin == 5 % A marker was specified |
---|
| 50 | plotMarkers = true; |
---|
| 51 | else |
---|
| 52 | plotMarkers = false; |
---|
| 53 | end |
---|
| 54 | |
---|
| 55 | % clf |
---|
| 56 | |
---|
| 57 | Nseg = size(seglist,1); |
---|
| 58 | |
---|
| 59 | hold on |
---|
| 60 | for s = 1:Nseg |
---|
| 61 | plot([seglist(s,1) seglist(s,3)], [seglist(s,2) seglist(s,4)],... |
---|
| 62 | 'LineWidth',lw, 'Color',col); |
---|
| 63 | if plotMarkers |
---|
| 64 | hold on |
---|
| 65 | plot([seglist(s,1) seglist(s,3)], [seglist(s,2) seglist(s,4)],marker); |
---|
| 66 | end |
---|
| 67 | end |
---|
| 68 | |
---|
| 69 | axis('equal'), axis('ij') |
---|
| 70 | |
---|
| 71 | |
---|