MATLAB R2011b 中三角化 3d 曲面的不稳定数据光标行为 [英] Erratic data cursor behavior for triangulated 3d surfaces in MATLAB R2011b

查看:13
本文介绍了MATLAB R2011b 中三角化 3d 曲面的不稳定数据光标行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当应用于三角化 3d 曲面图时,我发现 MATLAB R2011b 中的数据光标出现不稳定行为:单击某些点会选择完全不同的点.圆柱体示例:

I'm seeing erratic behavior from the data cursor in MATLAB R2011b when applied to plots of triangulated 3d surfaces: Clicking on certain points selects completely different points instead. Example with a cylinder:

[r, phi, h] = meshgrid(1, 0:pi/10:2*pi, 0:0.05:1);
x = r.*cos(phi);
y = r.*sin(phi);
z = h;
xyz = [x(:) y(:) z(:)];
tri = delaunay(xyz);
trimesh(tri, xyz(:,1), xyz(:,2), xyz(:,3), ...
        'LineStyle', 'none', 'Marker', '.', 'MarkerSize', 30)
view(-37, 28)

然后启用数据光标模式并尝试选择前面一列的最上面的点.在我的安装中,MATLAB 没有选择光标下的点,而是一个看似随机选择的不同点.

Then enable data cursor mode and try to select the topmost dot of one of the columns in front. On my installation, MATLAB does not select the point under the cursor but a different one seemingly chosen at random.

这是一个错误还是我做错了什么?

Is this a bug or am I doing something wrong?

推荐答案

我在 Jochen Rau 的文件交换贡献.您可以通过 'HitTest' 属性定义可以使用数据光标选择哪些数据.因此,对于我提供的示例,我只希望标记可选,解决方案是绘制没有标记的网格,并将HitTest"设置为关闭",然后使用scatter3"绘制标记.

I found a solution to this problem in a File Exchange contribution by Jochen Rau. You can define which data is selectable with the data cursor via the 'HitTest' property. So for the example I provided, where I wanted only the markers to be selectable, the solution is to plot the mesh without markers and with 'HitTest' set to 'off' and then use 'scatter3' to plot the markers.

[r, phi, h] = meshgrid(1, 0:pi/10:2*pi, 0:0.05:1);
x = r.*cos(phi);
y = r.*sin(phi);
z = h;
xyz = [x(:) y(:) z(:)];
tri = delaunay(xyz);
figure
hold on
trimesh(tri, xyz(:,1), xyz(:,2), xyz(:,3), ...
        'LineStyle', 'none', 'Marker', 'none', 'HitTest', 'off')
scatter3(xyz(:,1), xyz(:,2), xyz(:,3))
view(-37, 28)

如果您想知道绘制三角剖分的意义是什么:它是为了通过隐藏后面的点来帮助可视化点云.'trimesh' 调用实现了这一点,因为它仍然以白色绘制面部.

If you're wondering what the point of plotting the triangulation is: it's to aid in visualizing point clouds by obscuring points that are in the back. The 'trimesh' call accomplishes this because it still draws the faces in white.

这篇关于MATLAB R2011b 中三角化 3d 曲面的不稳定数据光标行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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