필터 지우기
필터 지우기

How to efficiently compute normal to a surface given surface points

조회 수: 17 (최근 30일)
alegio20
alegio20 2021년 3월 8일
댓글: darova 2021년 3월 8일
Hi everyone,
I am struggling to understand how to compute normal to a surface on ML.
I have a very simple geometry made by a cone divided both in height and along the circumference, and what I would like as outputs for every area in which the cone is divided are:
  • The centroid of every single area;
  • The normal to the area centered on the centroid.
The output I would like is formed by a matrix for the centroids and a matrix for the normals in which each row is formed by a triplet X, Y, Z of the coordinates and values of the centroids and normals respectively.
I attach part of the code for generating a simple cone.
n = 36; % Number of divisions along the circumference
hi = 1; % Number of divisions along the height of the cone (needed for another part of the code)
H = 5; % Height of the cone
r = zeros (1,H/hi);
R = 3; % Base radius
for i = 1:H/hi
r(i) = (1-i*hi/H)*R;
end
[x,y,z] = cylinder(r,n);
z = z*H;

채택된 답변

darova
darova 2021년 3월 8일
  댓글 수: 2
alegio20
alegio20 2021년 3월 8일
편집: alegio20 2021년 3월 8일
Thanks, i have alredy tried surfnorm but it doesn't calculates where I need to and just calculates it at intesections between areas. Not in the centers.
darova
darova 2021년 3월 8일
You can calculate vector field (u,v,w) and interpolate it where you need
[u,v,w] = surfnorm(x,y,z);
u1 = interp2(x,y,u,x1,y1);
v1 = interp2(x,y,v,x1,y1);
w1 = interp2(x,y,w,x1,y1);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by