1 function B=SnakeInternalForceMatrix3D(FV,alpha,beta,gamma)
\r
3 % B=SnakeInternalForceMatrix3D(F,alpha,beta,gamma)
\r
6 % FV : Struct (Patch) with the triangulated surface
\r
7 % alpha : membrame energy (first order)
\r
8 % beta : thin plate energy (second order)
\r
9 % gamma : Step Size (Time)
\r
12 % B : The Snake Smoothness regulation matrix
\r
14 % Function is written by D.Kroon University of Twente (July 2010)
\r
16 Ne=VertexNeighbours(FV.faces,FV.vertices);
\r
17 nV=size(FV.vertices,1);
\r
19 % Matrix for umbrella mesh derivative function in (sparce) matrix form
\r
20 NeMatrix = spalloc(nV,nV,nV*10);
\r
23 % Add the neighbours
\r
24 NeMatrix(i,Nc)=1/length(Nc);
\r
25 % Add the vertex it self
\r
29 % Total internal force matrix
\r
30 B=inv(gamma*speye(nV,nV)-alpha*NeMatrix+beta*NeMatrix*NeMatrix);
\r
32 function Ne=VertexNeighbours(F,V)
\r
33 % Function which return the neighbouring vertices of every vertex
\r
34 % in a cell array list. (Basic version, not sorted by rotation)
\r
36 % Neighbourh cell array
\r
37 Ne=cell(1,size(V,1));
\r
39 % Loop through all faces
\r
41 % Add the neighbors of each vertice of a face
\r
42 % to his neighbors list.
\r
43 Ne{F(i,1)}=[Ne{F(i,1)} [F(i,2) F(i,3)]];
\r
44 Ne{F(i,2)}=[Ne{F(i,2)} [F(i,3) F(i,1)]];
\r
45 Ne{F(i,3)}=[Ne{F(i,3)} [F(i,1) F(i,2)]];
\r
48 % Remove duplicate vertices
\r
49 for i=1:size(V,1), Ne{i}=unique(Ne{i}); end
\r