Hi @ ehsan,
After analyzing your code and addressing your query, “Why is the grad(H) has that dimension? where is the mistake?”
When you are trying to solve grad_H, you multiply it by mean_curvature, which may lead to dimension mismatches unless mean_curvature is appropriately reshaped or indexed and the output of grad(V,F) is structured in such a way that it may not directly align with your expectations for vertex-wise operations if you do not not handle them correctly. So, to resolve the issue you should solve the gradient of mean curvature, so you can properly handle its application across vertices. Here is the snippet code,
% Load a mesh
[V, F] = load_mesh('sphere.off');
% Compute Cotangent Laplacian (L) and Mass Matrix (M)
L = cotmatrix(V, F);
M = massmatrix(V, F, 'barycentric');
% Compute Mean Curvature Vector (H)
H = -inv(M) * (L * V); % This should be [162, 3] for vertices
% Compute the Magnitude of Mean Curvature
mean_curvature = sqrt(sum(H.^2, 2)); % This will be [162, 1]
% Compute the Normal Vector
normals = per_vertex_normals(V, F);
% Compute Gaussian Curvature
gaussian_curvature = discrete_gaussian_curvature(V,F);
% Compute Laplacian of Mean Curvature
laplacian_H = L * mean_curvature;
% Correctly compute the Gradient of Mean Curvature
G = grad(V,F); % G will be [#faces*dim, #vertices]
mean_curvature_vector = repmat(mean_curvature, 1, size(G, 1)/size(V,
1)); % Reshape as necessary
grad_H = G * mean_curvature_vector'; % Ensure proper multiplication
% Compute new term: newthing
H_squared = mean_curvature .^ 2;
newthing = laplacian_H + ((H_squared - 2 * gaussian_curvature) .*
mean_curvature) .* normals + mean_curvature .* grad_H;
% Define small arc equation
h = 0.1;
vertex = V;
f_h = vertex + (mean_curvature .* normals) * h + newthing * (h^2 / 2);
After implementing these changes, verify that your outputs align with expected physical behaviors and characteristics of curvature in your mesh.Also, consider adding unit tests for smaller meshes to validate your calculations independently before scaling up to larger datasets. Hope this helps, please let me know if you any further questions.
FYI, I couldn’t download “ sphere.off” since I am using MATLAB mobile.