Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
Windel Hotdog
Windel Hotdog le 22 Sep 2022
Réponse apportée : Moksh le 12 Sep 2023
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.

Réponses (1)

Moksh
Moksh le 12 Sep 2023
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

Catégories

En savoir plus sur Mining Geology dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by