Calculate normals from nodes which generate a 3D curve

4 ビュー (過去 30 日間)
Alberto Acri
Alberto Acri 2024 年 8 月 2 日
回答済み: Gayathri 2024 年 8 月 14 日
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 件のコメント
Alberto Acri
Alberto Acri 2024 年 8 月 9 日
missing code snippet
Umar
Umar 2024 年 8 月 9 日
Hi @ Alberto Acri,
Please see “missing code snippet” updated in my recent post.

サインインしてコメントする。

回答 (1 件)

Gayathri
Gayathri 2024 年 8 月 14 日
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.

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by