使用datacursor计算3D图形的2个点之间的距离 [英] Computing distance between between 2 point of a 3D figure using datacursor

查看:91
本文介绍了使用datacursor计算3D图形的2个点之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个GUI,该GUI通过按下按钮来绘制3D图形.当我使用图中的datacursormode选择2点时,我试图返回2点之间的距离值.我知道计算距离的公式,但是我不知道如何使数据游标返回所选的2个点的(X,Y,Z)值.

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.

谢谢.

推荐答案

%// 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 ;


这假设您在当前图中已经有2个数据提示. 每个"Coordinates_Datatip"变量将包含您数据提示的3个标量值x,y和z位置.


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.

这篇关于使用datacursor计算3D图形的2个点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆