1 function FV=MakeContourClockwise3D(FV)
\r
2 % This function MakeContourClockwise will make a surface clockwise
\r
3 % contour clockwise. This is done by calculating the volume inside the
\r
4 % surface, if it is negative we change the surface orientation.
\r
6 % FV=MakeContourClockwise2D(FV);
\r
9 % FV : Triangulated surface description with FV.faces and FV.vertices
\r
11 % Function is written by D.Kroon University of Twente (July 2010)
\r
13 % Volume inside contour
\r
15 for i=1:size(FV.faces,1)
\r
16 a=FV.vertices(FV.faces(i,1),:); b=FV.vertices(FV.faces(i,2),:); c=FV.vertices(FV.faces(i,3),:);
\r
19 v = (a(1)*k(1)+a(2)*k(2)+a(3)*k(3))/6;
\r
25 % If the area inside the contour is positive, change from counter-clockwise to
\r
28 FV.faces=[FV.faces(:,3) FV.faces(:,2) FV.faces(:,1)];
\r
31 function c=cross(a,b)
\r
33 c = [a(2,:).*b(3,:)-a(3,:).*b(2,:)
\r
34 a(3,:).*b(1,:)-a(1,:).*b(3,:)
\r
35 a(1,:).*b(2,:)-a(2,:).*b(1,:)];
\r