필터 지우기
필터 지우기

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

조회 수: 5 (최근 30일)
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!

채택된 답변

Matt J
Matt J 2017년 8월 15일
편집: Matt J 2017년 8월 15일
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
Sterling Baird
Sterling Baird 2020년 6월 26일
편집: Sterling Baird 2020년 6월 26일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 8월 15일
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
Sterling Baird
Sterling Baird 2022년 2월 5일
@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 2022년 2월 5일
편집: John D'Errico 2022년 2월 5일
@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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by