Calculate normals from nodes which generate a 3D curve

5 visualizaciones (últimos 30 días)
Alberto Acri
Alberto Acri el 2 de Ag. de 2024
Respondida: Gayathri el 14 de Ag. de 2024
Hi! I have two matrices:
  • the matrix 'coord' containing the coordinates of nodes (see black nodes in the figure)
  • a matrix 'normals' having in each row the normal N=[a,b,c] (a: first column, b: second column, c: third column) for the first 10 nodes in 'coord'.
How can I determine the normals of the other nodes in 'coord' by following the trend of the nodes (red line in figure)?
load("test_pp.mat")
figure
plot3(coord(:,1),coord(:,2),coord(:,3),'k.','Markersize',20);
hold on
plot3(coord(:,1),coord(:,2),coord(:,3),'-r','LineWidth',2);
hold off
axis equal
EDIT: re-formulated question
  5 comentarios
Alberto Acri
Alberto Acri el 9 de Ag. de 2024
missing code snippet
Umar
Umar el 9 de Ag. de 2024
Hi @ Alberto Acri,
Please see “missing code snippet” updated in my recent post.

Iniciar sesión para comentar.

Respuestas (1)

Gayathri
Gayathri el 14 de Ag. de 2024
To calculate the “normals” of remaining entries in matrix “coord” we can do interpolation in 3-D space. This can be done using the function “scatteredInterpolant”. This function performs interpolation on scattered data that resides in 2-D or 3-D space. For more information, please refer the below mentioned link.
Then the new “normal” values can be found using the interpolant obtained in the above-mentioned method.
Please find the code below for your reference.
load("test_pp.mat")
known_coords=coord(1:10,:);
F_x = scatteredInterpolant(known_coords(:,1), known_coords(:,2), known_coords(:,3), normals(:,1), 'natural', 'linear');
F_y = scatteredInterpolant(known_coords(:,1), known_coords(:,2), known_coords(:,3), normals(:,2), 'natural', 'linear');
F_z = scatteredInterpolant(known_coords(:,1), known_coords(:,2), known_coords(:,3), normals(:,3), 'natural', 'linear');
% Interpolate normals for the remaining points
remaining_coords = coord(11:end, :);
interp_normals = zeros(size(remaining_coords));
for i = 1:size(remaining_coords, 1)
interp_normals(i, 1) = F_x(remaining_coords(i, 1), remaining_coords(i, 2), remaining_coords(i, 3));
interp_normals(i, 2) = F_y(remaining_coords(i, 1), remaining_coords(i, 2), remaining_coords(i, 3));
interp_normals(i, 3) = F_z(remaining_coords(i, 1), remaining_coords(i, 2), remaining_coords(i, 3));
end
% Combine known and interpolated normals
all_normals = [normals; interp_normals];
% Display results
disp(all_normals)
Hope you find this information helpful.

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by