convhull/convhulln: data is coplanar/data is degenerate in at least one dimension (I know it is, but it is supposed to be.)

13 vues (au cours des 30 derniers jours)
Hi there! I have got some data that represents points on planes that are oriented somehow in three dimensional space. As such, the data is coplanar by nature. I want to calculate the area that is covered on the plane on which the data is located, but convhull and convhulln both refuse to do this. I assume the problem is that it would try to calculate a volume which would always come out to zero. Can I force the calculation to get the area or do I need to project the data into a 2D coordinate system first? cheers!

Réponse acceptée

Matt J
Matt J le 15 Août 2017
Modifié(e) : Matt J le 15 Août 2017
Yes, you do have to project them, but it's not too hard. Assumings "points" is an Nx3 array,
[U,S]=svd( bsxfun(@minus,points,mean(points)), 0);
[~,area]=convhull(U*S(:,1:2));
  3 commentaires
Sterling Baird
Sterling Baird le 26 Juin 2020
Modifié(e) : Sterling Baird le 26 Juin 2020
If you add more points to the "compressed" plane, the way to convert up to 3D is:
[U,S,V]=svd(bsxfun(@minus,pts,mean(pts)),0); % pts == U*S*V'
subdivpts = [0.5 0.5; 1 1; 1 0.5; 2 2]; %define new subdivised (2D) points
newpts = padarray(subdivpts,[0 1],'post')*V'+mean(pts); %add column of zeros to get new U*S, then post-multiply by V'
Note that this is also general to compressing/projecting/compacting a hyperplane from n to n-1 dimensions, where the only change is that pts and divpts are k x n matrices, k === # pts.
Thank you @Matt J, this was very helpful for what I was trying to do.

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 15 Août 2017
Can you attach the data?
One approach might be to get a rotated coordinate system with pca(). Then ignore the coordinate along the thin direction and get the convex hull from that 2-D projection. Then use polyarea() to get the area.
For example, let's say you have a wide expanse in the x and y direction and some but very little in the z direction. Then pass just a and y into convhull() and take the returned points and pass those points only into polyarea. pca() is just the same except it will handle tilted planes, not just those aligned with the axes, because it defines new axes.
Hope you followed that - you probably will if you know about principal components analysis.
I attach my only pca demo, though it doesn't do exactly what you want, but perhaps it might be instructive nonetheless.
  3 commentaires
Sterling Baird
Sterling Baird le 5 Fév 2022
@Image Analyst or @Matt J could you comment on how the solution suggested by @Matt J differs from PCA? (or is it identical?)
John D'Errico
John D'Errico le 5 Fév 2022
Modifié(e) : John D'Errico le 5 Fév 2022
@Sterling Baird - The use of SVD there on the mean subtracted data makes it the same as PCA, assuming the projection via SVD is done into the plane of the first two components from PCA. In fact, one can do PCA enirely from the output from SVD, but use of PCA is a little more friendly to someone who does not truly understand the mathematics required to build such a tool.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Dimensionality Reduction and Feature Extraction dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by