www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@cgsurfacedragger/pClosestPoint.m
function out = pClosestPoint(h, clickLine) %PCLOSESTPOINT. Private function. Identifies the closest point to a mouse click on the surface % % clickLine is the "currentpoint" on the axes. See the Matlab help. % % Returns structure "out" with members: % x,y,z - coordinates of nearest point to where click line intersects surface % xidx, yidx - indices of this point in surface xdata & ydata % % or empty, if no intersection was found. % % Note that only x & y coords between those specified in clickLine are % tested. % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. [P V I] = vertexpicker(h.SurfaceHandle, clickLine, '-force'); if isempty(P) out = []; else out.z = V(3); out.x = V(1); out.y = V(2); [out.yidx, out.xidx] = ind2sub(size(h.ZData)', I); end