source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/graphics/draw_line_clip.m @ 37

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

Added original make3d

File size: 751 bytes
Line 
1function h = draw_line_clip(m,b,a, linespec, varargin)
2%DRAW_LINE_CLIP  Draw a line defined by an equation.
3% DRAW_LINE_CLIP(M,B,A) draws a line, clipped to the current axes,
4% defined by a*y = m*x + b.
5% DRAW_LINE_CLIP(M,B,A,LINESPEC) also specifies the line style and color.
6
7if nargin < 4
8  linespec = 'b';
9end
10v = axis;
11x1 = v(1);
12x2 = v(2);
13warning off
14y1 = (m*x1 + b)/a;
15y2 = (m*x2 + b)/a;
16warning on
17if y1 < v(3)
18  y1 = v(3);
19  x1 = (a*y1 - b)/m;
20end 
21if y1 > v(4)
22  y1 = v(4);
23  x1 = (a*y1 - b)/m;
24end 
25if y2 < v(3);
26  y2 = v(3);
27  x2 = (a*y2 - b)/m;
28end
29if y2 > v(4);
30  y2 = v(4);
31  x2 = (a*y2 - b)/m;
32end
33h = line([x1 x2], [y1 y2]);
34set_linespec(h,linespec);
35if length(varargin) > 0
36  set(h,varargin{:});
37end
38if nargout < 1
39  clear h
40end
Note: See TracBrowser for help on using the repository browser.