Code covered by the BSD License

### Highlights from polygeom.m

4.84615
4.8 | 13 ratings Rate this file 95 Downloads (last 30 days) File Size: 38.9 KB File ID: #319 Version: 1.2

# polygeom.m

### H.J. Sommer (view profile)

09 Oct 1998 (Updated )

POLYGEOM computes area, centroid location, area moments of inertia and perimeter of closed polygons.

File Information
Description

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.

Acknowledgements

This file inspired Co Blade: Software For Analysis And Design Of Composite Blades.

MATLAB release MATLAB 5.2 (R10)
04 Dec 2014 Nele Gerrits

### Nele Gerrits (view profile)

Does it also work for an arbitrarily shaped form?

Comment only
29 Jan 2013 charlie

### charlie (view profile)

Excellent program.

Question: Is J = Iuu + Ivv valid only for circular cross sections?

01 Oct 2011 Steve Tweddell

### Steve Tweddell (view profile)

Excellent function, a real time saver

14 Apr 2011 Richard Crozier

### Richard Crozier (view profile)

14 Apr 2011 Richard Crozier

### Richard Crozier (view profile)

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,

% 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)

xy = [0.5, 0.1667;
0.8333, 0.5;
1, 1;
0.5694, 0.5694; ];

x = xy(:,1);
y = xy(:,2);

for i = 1:numel(x)-1
line(x(i:i+1), y(i:i+1), [0,0], 'Color', 'b');
hold on
end

line([x(end), x(1)], [y(end), y(1)], [0,0], 'Color', 'b');

[ geom, iner, cpmo ] = polygeom( x, y )

plot(geom(2), geom(3), '+r')

hold off

Comment only
23 Feb 2011 Raghuram

### Raghuram (view profile)

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.

Comment only
08 Jun 2009 Stefan Berger

### Stefan Berger (view profile)

This prog is wonderful, just what I needed. If you have time please improve it to handle the third dimension!!

29 Nov 2008 Xu

29 Nov 2008 Xu

### Xu (view profile)

Comment only
15 Apr 2008 Alice Huang
04 Dec 2006 Pooya S

Nice package

22 Mar 2006 Jim Price

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.