Green’s theorem and section properties
January 17, 2018 at 11:07 AM by Dr. Drang
In the last post, I presented a simple Python module with functions for calculating section properties of polygons. Now we’ll go through the derivations of the formulas used in those functions.
The basis for all the formulas is Green’s theorem, which is usually presented something like this:
where and are functions of and , is the region over which the right integral is being evaluated, and is the boundary of that region. The integral on the right is evaluated in accordance with the right-hand rule, i.e., counterclockwise for the usual orientation of the and axes.
The section properties of interest are all area integrals. We’ll use Green’s theorem to turn them into boundary integrals and then evaluate those integrals using the coordinates of the polygon’s vertices.
Area
This is the easiest one, but instead of going through the full derivation here, I’ll refer you to this excellent StackExchange page by apnorton and just hit the highlights.
The area is defined
and we’ll choose and as our Greens’ theorem functions. This gives us
We break the polygonal boundary into a series of straight-line segments, each of which can be parameterized this way:
where the are the coordinates of the vertices.
Plugging these equations into the integral, we get
A note on the indexing: The polygon has vertices, which we’ll number from 0 to . The last segment of the boundary goes from to . To make this work with the equation, we’ll define .
Let’s compare this with the area
function in the module:
python
def area(pts):
'Area of cross-section.'
if pts[0] != pts[-1]:
pts = pts + pts[:1]
x = [ c[0] for c in pts ]
y = [ c[1] for c in pts ]
s = 0
for i in range(len(pts) - 1):
s += x[i]*y[i+1] - x[i+1]*y[i]
return s/2
We start by checking the pts
list to see if the starting and ending items match. If they don’t, we copy the starting item to the end to fit the indexing convention discussed above. We then initialize some variables and execute a loop, summing terms along the way. Rewriting the loop in mathematical terms, we get
This doesn’t look like the equation derived from Green’s theorem, does it? But it’s not too hard to see that they are equivalent. Expanding out the binomial product in the earlier equation gives
As we loop through all the values of from 0 to , the leading term of one trip through the loop will cancel the trailing term of the next trip through the loop. Here’s an example for a triangle:
After the cancellations, all that’s left are the inner terms, and that’s the formula used in the area
function.
The cancellation doesn’t do much for us here, changing from two additions and one multiplication per loop to two multiplications and one addition per loop. But we’ll see this same sort of cancellation in the other section properties, and it will provide greater simplification in those.
Centroid
The centroid is essentially the average position of the area. If a sheet of material of uniform thickness and density were cut into a shape, the centroid would be the center of gravity, the balance point, of that shape. The coordinates of the centroid are defined this way:
Let’s derive the formula for for a polygon; the derivation of the formula for will be similar.
In applying Green’s theorem, we’ll take and . Therefore,
Breaking the polygonal boundary into straight-line segments and using the same parametric equations as before, we get an integral that looks like this
for each segment. This integral evaluates to
so our formula for the centroid is
As we found in the formula for area, the leading and trailing terms in the expansion of this product cancel out as we loop through the sum, leaving us with
This looks like a mess, but it can be factored into a more compact form:
The expression for the other centroidal coordinate is as you’d expect:
These are the formulas used in the centroid
function.
python:
def centroid(pts):
'Location of centroid.'
if pts[0] != pts[-1]:
pts = pts + pts[:1]
x = [ c[0] for c in pts ]
y = [ c[1] for c in pts ]
sx = sy = 0
a = area(pts)
for i in range(len(pts) - 1):
sx += (x[i] + x[i+1])*(x[i]*y[i+1] - x[i+1]*y[i])
sy += (y[i] + y[i+1])*(x[i]*y[i+1] - x[i+1]*y[i])
return sx/(6*a), sy/(6*a)
Moments and product of inertia
You may be familiar with moments and products of inertia from dynamics, where the terms are related to the distribution of mass in a body. The moments and product of inertia we’ll be talking about here—more properly called the second moments of area—are mathematically similar and refer to the distribution of area across a planar shape.
The moments and product of inertia that matter in beam bending are taken about the centroidal axis (i.e., a set of and axes with the origin at the centroid of the shape). Since we don’t know where the centroid is when we set up our coordinate system, our list of vertex points don’t work off that basis. But we can still calculate the centroidal moments and product of inertia by using these formulas:
We’ll concentrate on ; the other two will be similarly derived.
First, let’s expand the square inside the integral and see what we get:
The integral in the second term is and the integral in the third term is just . Putting this together, we get1
Since we already have formulas for and , we can concentrate on the integral in the first term on the right.
Returning to Green’s theorem, we’ll use and , giving us
Once again, we break the polygonal boundary into straight-line segments and use parametric equations to define the segments. For each segment, we’ll get the following integral:
This integral evaluates to
giving us
Once again, if we expand out the product inside the sum, we’ll find that the leading and trailing terms cancel as we work through the loop. That gives us
And that long expression can be factored, leaving
Similar2 derivations give us
These formulas, and the terms accounting for the location of the centroid, are in the function inertia
.
python:
def inertia(pts):
'Moments and product of inertia about centroid.'
if pts[0] != pts[-1]:
pts = pts + pts[:1]
x = [ c[0] for c in pts ]
y = [ c[1] for c in pts ]
sxx = syy = sxy = 0
a = area(pts)
cx, cy = centroid(pts)
for i in range(len(pts) - 1):
sxx += (y[i]**2 + y[i]*y[i+1] + y[i+1]**2)*(x[i]*y[i+1] - x[i+1]*y[i])
syy += (x[i]**2 + x[i]*x[i+1] + x[i+1]**2)*(x[i]*y[i+1] - x[i+1]*y[i])
sxy += (x[i]*y[i+1] + 2*x[i]*y[i] + 2*x[i+1]*y[i+1] + x[i+1]*y[i])*(x[i]*y[i+1] - x[i+1]*y[i])
return sxx/12 - a*cy**2, syy/12 - a*cx**2, sxy/24 - a*cx*cy
This older post explains the use of the moment of inertia in beam bending, but I avoided the trickier bits associated with the product of inertia and principal axes. We’ll cover them in the next post.
Update Jan 23, 2018 12:42 PM Thanks to Glenn Walker for finding an error in one of the formulas. They’re more annoying to me than mistakes in the text.
-
Yes, this is the parallel axis theorem. ↩
-
Yes, the product of inertia integral is definitely more complicated if you’re going to do the derivation by hand. So don’t do it by hand. Learn SymPy and you’ll be able to zip through it. ↩