Home > vbmeg > functions > tool_box > select3d_dir > demo_surface.m

demo_surface

PURPOSE ^

DEMO_SURFACE

SYNOPSIS ^

function demo_surface(arg)

DESCRIPTION ^

DEMO_SURFACE
  Demonstrates SELECT3D. Click on the surface plot
  and you should see the 3-D point selected along with
  the nearest vertex.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function demo_surface(arg)
0002 %DEMO_SURFACE
0003 %  Demonstrates SELECT3D. Click on the surface plot
0004 %  and you should see the 3-D point selected along with
0005 %  the nearest vertex.
0006 
0007 %  Copyright Joe Conti 2002
0008 %  Send comments to jconti@mathworks.com
0009 
0010 if nargin>0
0011     feval(arg);
0012     return;
0013 end
0014 
0015 fig = figure;
0016 surf(peaks); drawnow;
0017 zoom(4);
0018 axis manual; % Prevent resize
0019 
0020 set(gca,'projection','o');
0021 
0022 % Markers
0023 selection_marker = line('marker','o','markerfacecolor','k','erasemode','xor','visible','off');
0024 selection_vertex = line('marker','o','markerfacecolor','k','erasemode','xor','visible','off');
0025 selection_face = line('marker','o','markerfacecolor','k','erasemode','xor','visible','off');
0026 
0027 setappdata(0,'selection_marker',selection_marker);
0028 setappdata(0,'selection_vertex',selection_vertex);
0029 setappdata(0,'selection_face',selection_face);
0030 
0031 set(fig,'windowbuttondownfcn','demo_surface(''update'')');
0032 
0033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0034 function update
0035 
0036 [p v vi face facei] = select3d(gco);
0037 
0038 if isempty(p)
0039     return
0040 end
0041 
0042 selection_marker = getappdata(0,'selection_marker');
0043 selection_vertex = getappdata(0,'selection_vertex');
0044 selection_face = getappdata(0,'selection_face');
0045 
0046 set(selection_marker,'visible','on','xdata',p(1),'ydata',p(2),'zdata',p(3));
0047 
0048 set(selection_vertex,'visible','on','xdata',v(1),'ydata',v(2),'zdata',v(3));
0049 disp(sprintf('\nX: %.2f\nY: %.2f\nZ: %.2f',p(1),p(2),p(3)'))

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005