POLYGEOM computes area, centroid location, area moments of inertia and perimeter of closed polygons.
This function is useful for bending/torsion stress analyses, area centroids of models for wind tunnel testing, rotational inertia for dynamics and blob analysis for image processing.
Raghuram, the correct answer is given if you reorder your vertices so they are given clockwise around the outside of the polygon, rather than just specified randomly, e.g,
% Your vertices
% x = [1.0000 0.5000 0.8333 0.5694];
% y = [1.0000 0.1667 0.5000 0.5694] ;
% reordered moving clockwise around the polygon from (0.5, 0.1667)
The outputs are erroneous for the following input:
x = [1.0000 0.5000 0.8333 0.5694]
y = [1.0000 0.1667 0.5000 0.5694]
The centroid is computed as (0.8801,1.1496) which is outside the parallelogram formed by the input points.
Yes, yes, yes --- this is an extremely useful and well-done script. Should be a part of the regular Matlab so that users can most easily find it. Thank You!!
31 Oct 2005
Alfonso Rojas
Very useful program, clean and well-commented code. Tried it with Matlab
v 7.0.1 (R14), and it works fine. Excellent.
30 Aug 2005
Chinmay Pangarkar
Super!!! I get all geometry of my arbitrary cells using this code. Thank you H.J. Sommer!!
07 Apr 2005
Thor I. Fossen
Excellent program. Should be standard in Matlab. I have used it compute the centroids for wind and current projected areas as welll as other things:)
23 Jan 2004
Finlay Scott
Very useful for getting the perimeter of cyclic predator-prey ecological systems
10 Sep 2003
Elvis Dieguez
Excellent program! Saved me lots of time trying to calculate the area surveyed by a moving wheeled sensor system.
Updates
12 Jan 2005
Provides positive area for CW or CCW vertex sequence.
30 Nov 2008
derivation and test routine added to ZIP on 08.11.30