polygon_average, a Python code which demonstrates a process of repeatedly averaging and normalizing the vertices of a polygon, illustrating a property of the power method.
The process can be analyzed in terms of the power method, and the eigenvalues of the matrix that carries out the averaging process.
A polygon is represented by a list of N vertices. An averaging step involves:
If the averaging process is carried out recursively, the resulting polygon rapidly converges to an ellipse at a 45 degree tilt.
The direction of the tilt, and the ratio between the major and minor axis lengths, vary depending on the initial polygon.
The computer code and data files made available on this web page are distributed under the GNU LGPL license.
polygon_average is available in a MATLAB version and an Octave version and a Python version.
polygon, a Python code which carries out geometric calculations on polygons, including angles, area, centroid, containment of a point, diameter, integrals of monomials, convexity, distance to a point, sampling, triangulation.
power_method, a Python code which carries out the power method for finding a dominant eigenvalue and its eigenvector.