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

convhull convhulln coplanar degenerate dimension 3d planeStatistics and Machine Learning Toolbox

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!

Best Answer

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));