Home > matGeom > graphs > meshEnergy.m

meshEnergy

PURPOSE ^

MESHENERGY Computes the energy of a tesselation, as the sum of second area moments.

SYNOPSIS ^

function energy = meshEnergy(vertices, faces)

DESCRIPTION ^

MESHENERGY Computes the energy of a tesselation, as the sum of second area moments.

   This function can be used to check that the total energy of Centroidal
   Voronoi Tesselation (CVT) decreases with the iterations of the Lloyd
   algorithm.

   E = meshEnergy(V, F)
   V is the list of mesh vertices, and F are faces, as a cell array of
   vertex indices.

   Example
   meshEnergy

   See also
     centroidalVoronoi2d, cvtUpdate, polygonSecondAreaMoments

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function energy = meshEnergy(vertices, faces)
0002 %MESHENERGY Computes the energy of a tesselation, as the sum of second area moments.
0003 %
0004 %   This function can be used to check that the total energy of Centroidal
0005 %   Voronoi Tesselation (CVT) decreases with the iterations of the Lloyd
0006 %   algorithm.
0007 %
0008 %   E = meshEnergy(V, F)
0009 %   V is the list of mesh vertices, and F are faces, as a cell array of
0010 %   vertex indices.
0011 %
0012 %   Example
0013 %   meshEnergy
0014 %
0015 %   See also
0016 %     centroidalVoronoi2d, cvtUpdate, polygonSecondAreaMoments
0017 
0018 % ------
0019 % Author: David Legland
0020 % E-mail: david.legland@inrae.fr
0021 % Created: 2017-09-01, using Matlab 9.1.0.441655 (R2016b)
0022 % Copyright 2017-2024 INRA - Cepia Software Platform
0023 
0024 nFaces = meshFaceNumber(vertices, faces);
0025 
0026 energyList = zeros(nFaces, 1);
0027 
0028 polygons = meshFacePolygons(vertices, faces);
0029 for i = 1:nFaces
0030     [Ix, Iy, Ixy] = polygonSecondAreaMoments(polygons{i}); %#ok<ASGLU>
0031     energyList(i) = hypot(Ix, Iy);
0032 end
0033 
0034 energy = sum(energyList);

Generated on Thu 21-Nov-2024 11:30:22 by m2html © 2003-2022