フィルターのクリア

How to prevent the far away points from connecting with "boundary" command?

3 ビュー (過去 30 日間)
Windel Hotdog
Windel Hotdog 2022 年 9 月 22 日
回答済み: Moksh 2023 年 9 月 12 日
Hi Community, i am using this command :
[k,vol_results] = boundary(results, 1); %with shrink factor = 1 (maximum shrink)
trisurf(k,results(:,1),results(:,2),results(:,3),'FaceColor','yellow','FaceAlpha',0.1)
However, the boundary plot still connect the two point which are far away, and give me the wrong volume. How could i use the boundary function to get a curve plot?
Thank you very much.

回答 (1 件)

Moksh
Moksh 2023 年 9 月 12 日
Hi Windel,
I understand that you are generating a boundary from a set of 3D coordinates using the “boundary” function in MATLAB, and you are trying to omit the far-off points to get a better-fitting boundary.
To achieve this, you can follow the below steps:
  • Calculate the centroid of the given set of points and determine the distance of each coordinate from this centroid.
  • Set a threshold distance and create a set of valid coordinates that will be used in the boundary generation.
  • Generate the boundary from this set of valid coordinates and keep varying the threshold distance until the desired results.
Here is an example code for the above logic:
%% Example x, y, z coordinates
x = round(rand(20, 1, "double") * 10);
y = round(rand(20, 1, "double") * 10);
z = round(rand(20, 1, "double") * 10);
points = [x y z];
plot3(x, y, z, '.', "MarkerSize", 10);
grid on
hold on
%% Thresholding logic
% Centroid Coordinates and plotting it
centroid = mean(points);
plot3(centroid(1), centroid(2), centroid(3), 'o', "MarkerFaceColor","green")
% Computing valid coordinates
cent_distance = vecnorm(points - centroid, 2, 2); % Distances from centroid
threshold_distance = 5; % Distance Threshold
val_ind = find(cent_distance <= threshold_distance); % Applying threshold
valid_coord = points(val_ind, :); % Valid coordinates
%% Computing boundary from these valid coordinates
k = boundary(valid_coord);
trisurf(k, x, y, z, 'Facecolor', 'red', 'FaceAlpha', 0.1)
Please refer to the below documentations for more information regarding the “vecnorm”, “find”, “boundary” and “trisurf” functions respectively:
Hope this helps!
Best Regards,
Moksh Aggarwal

カテゴリ

Help Center および File ExchangeMining Geology についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by