Rectifying compute_curvature.m error in Toolbox Graph in Matlab

조회 수: 7 (최근 30일)
Mark
Mark 2012년 10월 16일
댓글: iyyakutti iyappan 2016년 3월 8일
I am currently using the Toolbox Graph on the Matlab File Exchange to calculate curvature on 3D surfaces and find them very helpful (<http://www.mathworks.com/matlabcentral/fileexchange/5355>). However, the following error message is issued in “compute_curvature” for certain surface descriptions and the code fails to run completely:
Error in ==> compute_curvature_mod at 75 dp = sum( normal(:,E(:,1)) .* normal(:,E(:,2)), 1 ); ??? Index exceeds matrix dimensions.
This happens only sporadically, but there is no obvious reason why the toolbox works perfectly fine for some surfaces and not for others (of a similar topology). I also noticed that someone had asked about this bug back in March 2009 on File Exchange, but that the question had gone unanswered. The post states
"compute_curvature will generate an error on line 75 ("dp = sum( normal(:,E(:,1)) .* normal(:,E(:,2)), 1 );") for SOME surfaces. The error stems from E containing indices that are out of range which is caused by line 48 ("A = sparse(double(i),double(j),s,n,n);") where A's values eventually entirely make up the E matrix. The problem occurs when the i and j vectors create the same ordered pair twice in which case the sparse function adds the two s vector elements together for that matrix location resulting in a value that is too large to be used as an index on line 75. For example, if i = [1 1] and j = [2 2] and s = [3 4] then A(1,2) will equal 3 + 4 = 7.
The i and j vectors are created here: i = [face(1,:) face(2,:) face(3,:)]; j = [face(2,:) face(3,:) face(1,:)];
Just wanted to add that the error I mentioned is caused by the flipping of the sign of the surface normal of just one face by rearranging the order of the vertices in the face matrix"
I have tried debugging the code myself but have not had any luck. I am wondering if anyone here has solved the problem or could give me insight – I need the code to be sufficiently general-purpose in order to calculate curvature for a variety of surfaces, not just for a select few.
Thanks in advanced.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by