DRAWRAY Draw a ray on the current axis. drawRay(RAY) With RAY having the syntax: [x0 y0 dx dy], draws the ray starting from point (x0 y0) and going to direction (dx dy), clipped with the current window axis. drawRay(RAY, PARAMS, VALUE) Can specify param-pair values. H = drawRay(...) Returns handle on line object See also: rays2d, drawLine --------- author : David Legland INRA - TPV URPOI - BIA IMASTE created the 31/10/2003.
0001 function varargout = drawRay(ray, varargin) 0002 %DRAWRAY Draw a ray on the current axis. 0003 % 0004 % drawRay(RAY) 0005 % With RAY having the syntax: [x0 y0 dx dy], draws the ray starting from 0006 % point (x0 y0) and going to direction (dx dy), clipped with the current 0007 % window axis. 0008 % 0009 % drawRay(RAY, PARAMS, VALUE) 0010 % Can specify param-pair values. 0011 % 0012 % H = drawRay(...) 0013 % Returns handle on line object 0014 % 0015 % See also: 0016 % rays2d, drawLine 0017 % 0018 % --------- 0019 % 0020 % author : David Legland 0021 % INRA - TPV URPOI - BIA IMASTE 0022 % created the 31/10/2003. 0023 % 0024 0025 % HISTORY 0026 % 2005-07-06 add support for multiple rays 0027 % 2007-10-18 add support for drawing options 0028 % 2011-03-12 rewrite using clipRay 0029 % 2011-10-11 add management of axes handle 0030 0031 % extract handle of axis to draw in 0032 if isAxisHandle(ray) 0033 ax = ray; 0034 ray = varargin{1}; 0035 varargin(1) = []; 0036 else 0037 ax = gca; 0038 end 0039 0040 % get bounding box limits 0041 box = axis(ax); 0042 0043 % compute clipped shapes 0044 [clipped, isInside] = clipRay(ray, box); 0045 0046 % allocate memory for handle 0047 h = -ones(size(ray, 1), 1); 0048 0049 % draw visible rays 0050 h(isInside) = drawEdge(ax, clipped(isInside, :), varargin{:}); 0051 0052 % process output 0053 if nargout > 0 0054 varargout = {h}; 0055 end