Computing distance between between 2 point of a 3D figure using datacursor

痞子三分冷 提交于 2019-12-25 01:56:20

问题


I am building a GUI that plot a 3D figure by pressing button. I am trying to return a distance value between 2 points when I select the 2 points using datacursormode on the figure. I know the formula to calculate the distance, but I don't know how to make the data cursor return the (X,Y,Z) value of the 2 points selected.

Thanks.


回答1:


%// retrieve the data cursor manager for the figure  
dcm = datacursormode(gcf) ;

%// get all the datatips information in a structure  
dtip_info = dcm.getCursorInfo ;

%// extract the coordinates of each data tip from the structure  
Coordinates_Datatip1 = dtip_info(1).Position ;  
Coordinates_Datatip2 = dtip_info(2).Position ;

This assume you already have 2 datatips in the current figure. Each "Coordinates_Datatip" variable will contain 3 scalar values x,y and z position of your datatips.



来源:https://stackoverflow.com/questions/22691417/computing-distance-between-between-2-point-of-a-3d-figure-using-datacursor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!