source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/kovesi/hline.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1% HLINE - Plot 2D lines defined in homogeneous coordinates.
2%
3% Function for ploting 2D homogeneous lines defined by 2 points
4% or a line defined by a single homogeneous vector
5%
6% Usage:   hline(p1,p2)   where p1 and p2 are 2D homogeneous points.
7%          hline(p1,p2,'colour_name')  'black' 'red' 'white' etc
8%          hline(l)       where l is a line in homogeneous coordinates
9%          hline(l,'colour_name')
10%
11
12%  Peter Kovesi
13%  School of Computer Science & Software Engineering
14%  The University of Western Australia
15%  pk @ csse uwa edu au
16%  http://www.csse.uwa.edu.au/~pk
17%
18%  April 2000
19
20function hline(a,b,c)
21
22col = 'blue';  % default colour
23
24if nargin >= 2 & isa(a,'double')  & isa(b,'double')   % Two points specified
25
26  p1 = a./a(3);        % make sure homogeneous points lie in z=1 plane
27  p2 = b./b(3);
28
29  if nargin == 3 & isa(c,'char')  % 2 points and a colour specified
30    col = c;
31  end
32
33elseif nargin >= 1 & isa(a,'double')       % A single line specified
34
35  a = a./a(3);   % ensure line in z = 1 plane (not needed??)
36
37  if abs(a(1)) > abs(a(2))   % line is more vertical
38    ylim = get(get(gcf,'CurrentAxes'),'Ylim');
39    p1 = hcross(a, [0 1 0]');
40    p2 = hcross(a, [0 -1/ylim(2) 1]');
41  else                       % line more horizontal
42    xlim = get(get(gcf,'CurrentAxes'),'Xlim');
43    p1 = hcross(a, [1 0 0]');
44    p2 = hcross(a, [-1/xlim(2) 0 1]');
45  end
46
47  if nargin == 2 & isa(b,'char') % 1 line vector and a colour specified
48    col = b;
49  end
50
51else
52  error('Bad arguments passed to hline');
53end
54
55line([p1(1) p2(1)], [p1(2) p2(2)], 'color', col);
Note: See TracBrowser for help on using the repository browser.