使用散点确定未知3D曲面的法线向量

编程入门 行业动态 更新时间:2024-10-24 14:19:22
本文介绍了使用散点确定未知3D曲面的法线向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一组(拓扑上简单的) x,y,z 点.与它们每个相关联的是一个标量( s ).我想将结果可视化.

I have a set of (topologically simple) x,y,z points. Associated with each one of them is a scalar (s). I would like to visualize the results.

如何确定每个节点的(单位)法线,然后根据 s 进行缩放,或者有没有办法获得空间分布的表面图(与数据点平行绘制)飞机)?

How could I have the (unit) normal of each node determined and then scaled in accordance of s, or is there a way to get a spatially distributed surface plot (plotted parallel to the data points plane)?

这是3D点的示例:

推荐答案

如果未知曲面,则可以使用delaunay三角剖分法使用 delaunay 将曲面拟合到点上.然后,您可以使用 vertexNormal 查找法线向量.

If your surface is unknown, you can use delaunay to fit a surface on points using delaunay triangulation. Then you can find normal vectors using vertexNormal.

%% generating some sample data n = 1000; d = 6; zscale = 1/3; x = rand(n, 1)*d - d/2 ; y = rand(n, 1)*d - d/2; z = peaks(x, y)*zscale; s = 5./(1+(x.^2+y.^2)); %% calculating normal vectors T = delaunay(x,y); % triangulation connectivity matrix TR = triangulation(T,x,y,z); % the triangulation connectivity V = vertexNormal(TR); % normal vectors at triangle vertices

用于绘制以上图形的代码:

The code used to plot above figures:

figure, subplot 121 scatter3(x, y, z) [xg, yg, zg] = peaks(linspace(-d/2, d/2, 50)); zg = zg*zscale; mesh(xg, yg, zg) hold on scatter3(x, y, z, s*100, '.'); colormap jet axis equal, xlim([-d/2 d/2]), ylim([-d/2 d/2]) copyobj(get(subplot(121),'Children'),subplot(122)) legend('unknown surface', 'scattered data') axis equal, xlim([-d/2 d/2]), ylim([-d/2 d/2]) figure, subplot 121 hold on trisurf(T, x, y, z, 'edgealpha', 0.1) quiver3(x, y, z, ... V(:,1),V(:,2),V(:,3),2); grid on view(3) axis equal, xlim([-d/2 d/2]), ylim([-d/2 d/2]) colormap jet copyobj(get(subplot(121),'Children'),subplot(122)) legend('fitted surface', 'normal vectors') axis equal, xlim([-d/2 d/2]), ylim([-d/2 d/2]) figure, subplot 121 scatter3(x, y, z, '.') hold on quiver3(x, y, z, ... V(:,1).*s,V(:,2).*s,V(:,3).*s,5); view(3) axis equal, xlim([-d/2 d/2]), ylim([-d/2 d/2]) copyobj(get(subplot(121),'Children'),subplot(122)) legend('scattered points', 'scaled normal vectors') axis equal, xlim([-d/2 d/2]), ylim([-d/2 d/2])

更多推荐

使用散点确定未知3D曲面的法线向量

本文发布于:2023-07-17 17:11:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1135410.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:法线   向量   曲面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!