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, clipRay
0001 function varargout = drawRay(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, clipRay 0017 % 0018 0019 % ------ 0020 % Author: David Legland 0021 % E-mail: david.legland@inrae.fr 0022 % Created: 2003-10-31 0023 % Copyright 2003-2024 INRA - TPV URPOI - BIA IMASTE 0024 0025 % extract handle of axis to draw on 0026 [ax, varargin] = parseAxisHandle(varargin{:}); 0027 0028 % extract shape primitive 0029 ray = varargin{1}; 0030 varargin(1) = []; 0031 0032 % get bounding box limits 0033 box = axis(ax); 0034 0035 % compute clipped shapes 0036 [clipped, isInside] = clipRay(ray, box); 0037 0038 % allocate memory for handle 0039 h = -ones(size(ray, 1), 1); 0040 0041 % draw visible rays 0042 h(isInside) = drawEdge(ax, clipped(isInside, :), varargin{:}); 0043 0044 % process output 0045 if nargout > 0 0046 varargout = {h}; 0047 end