Transforming section properties and principal directions

The Python section module has one last function we haven’t covered: the determination of the principal moments of inertia and the axes associated with them. We’ll start by looking at how the moments and products of inertia change with our choice of axes.

The formula for area,

A=limits Adxdy

will give the same answer regardless of where we put the origin of the x-y coordinate system or how we orient them. You can see this if you think of the area as being the sum of all the little dxdy squares in the cross-section.

Region and nomenclature

The formulas for the location of the centroid,

x c=limits Axdxdy y c=limits Aydxdy

will give different answers for different positions and orientations of the x and y axes, but those answers will all correspond to same physical point of the cross-section.

The moments and product of inertia as we defined them, relative to the centroid,

I xx=limits A(yy c) 2dxdy I yy=limits A(xx c) 2dxdy I xy=limits A(yy c)(xx c)dxdy

do not depend on the position of the x-y origin (because xx c and yy c measure the horizontal and vertical distances away from the centroid, which is the same for any origin), but do depend on the orientation of the axes. We’ll show how this works by putting the origin at the centroid (which simplifies the math but does not make the results any less general) and comparing the moments and product of inertia for two coordinate systems, one of which is rotated relative to the other.

Rotated axes

Note that θ is the angle from the x axis to the ξ axis and is positive in the counterclockwise direction.1

Because our origin is at the centroid, x c=y c=ξ c=η c=0, and we can write the equations for the moments and products of inertia in a more compact form:

In the x-y system,

I xx=limits Ay 2dxdy I yy=limits Ax 2dxdy I xy=limits Axydxdy

and in the ξ-η system,

I ξξ=limits Aη 2dξdη I ηη=limits Aξ 2dξdη I ξη=limits Aξηdξdη

We can go back and forth between the two coordinate systems by noting that

ξ=xcosθ+ysinθ η=xsinθ+ycosθ

Thus,

I ξξ=limits A(x 2sin 2θ2xysinθcosθ+y 2cos 2θ)dxdy I ηη=limits A(x 2cos 2θ+2xysinθcosθ+y 2sin 2θ)dxdy I ξη=limits A((y 2x 2)sinθcosθ+xy(cos 2θsin 2θ))dxdy

The θ terms can come out of the integrals, leaving us with

I ξξ=sin 2θlimits Ax 2dxdy2sinθcosθlimits Axydxdy+cos 2θlimits Ay 2dxdy

or

I ξξ=I xxcos 2θ+I yysin 2θ2I xysinθcosθ

Similarly,

I ηη=I xxsin 2θ+I yycos 2θ+2I xysinθcosθ I ξη=(I xxI yy)sinθcosθ+I xy(cos 2θsin 2θ)

So far, this is just a bunch of algebra that could’ve been done quickly in SymPy. Now it’s time to start thinking.

Looking at the expression for I ξη, you might notice that each term includes parts from the double angle formulas. So we can rewrite it this way:

I ξη=12(I xxI yy)sin2θ+I xycos2θ

Note that I ξη=0 when

(I yyI xx)sin2θ=2I xycos2θ

or

tan2θ=2I xyI yyI xx

Because the tangent function repeats itself every 180°, this expression can be solved with an infinite number of values of θ that are 90° apart from one another. These orientations all look basically the same, except the ξ and η axes swap positions and flip around. For each of them, I ξη=0.

Since we’ve written the expression for I ξη in terms of 2θ, lets’s do the same for I ξξ and I ηη. We start by recognizing the double angle formula for sine in each equation:

I ξξ=I xxcos 2θ+I yysin 2θI xysin2θ I ηη=I xxsin 2θ+I yycos 2θ+I xysin2θ

Then we use the thoroughly non-obvious identity,2

Acos 2θ+Bsin 2θ=A+B2(cos 2θ+sin 2θ)+AB2(cos 2θsin 2θ)

and use the usual trig identities to get

Acos 2θ+Bsin 2θ=A+B2+AB2cos2θ

Therefore,3

I ξξ=I xx+I yy2I yyI xx2cos2θI xysin2θ

and

I ηη=I xx+I yy2+I yyI xx2cos2θ+I xysin2θ

Now let’s look at how these moments of inertia change with θ. Suppose we wanted to find the θ that maximized (or minimized) the value of I ξξ? We’d take the derivative of the expression for I ξξ and set it to zero:

dI ξξdθ=(I yyI xx)sin2θ2I xycos2θ=0

This should look familiar. It’s solution is

tan2θ=2I xyI yyI xx

the same thing we got setting I ξη=0. And if we took the derivative of I ηη with respect to θ and set it to zero to find the maxima and minima of I ηη, we’d get the same thing.

These orientations of the axes are known as the principal directions of the cross-section. They give us both a product of inertia of zero and the largest and smallest values of the moments of inertia. (If I ξξ is at a maximum, then I ηη is at a minimum, and vice versa.)

The largest and smallest moments of inertia are commonly called I 1 and I 2, respectively. They can be calculated by substituting our solution for θ back into the expressions for I ξξ and I ηη, but there’s some messy math along the way. It’s easier to recognize that the maximum and minimum moments of inertia are determined entirely by the second and third terms of I ξξ and I ηη, which are in the form

Acosα+Bsinα

This expression can be thought of as the horizontal projection of a pair of vectors, one of length A at an angle α to the horizontal and the other of length B at right angles to A.

Triangle of vectors

The largest value of this expression will come when the hypotenuse of the triangle, A 2+B 2, is itself horizontal and pointing to the right. The algebraically smallest value will come when the hypotenuse is horizontal and pointing to the left.

Applying this idea to our expressions for I ξξ and I ηη, the larger principal moment of inertia will be

I 1=I xx+I yy2+(I yyI xx2) 2+I xy 2

and the smaller will be

I 2=I xx+I yy2(I yyI xx2) 2+I xy 2

The axis associated with the larger principal moment of inertia is called the major principal axis and the axis associated with the smaller principal moment of inertia is called the minor principal axis. These are sometimes called the strong and weak axes, respectively. Whatever you call them, they’ll be 90° apart.

Now let’s look at the principal function from the section module and see how these formulas were used.

python:
def principal(Ixx, Iyy, Ixy):
  'Principal moments of inertia and orientation.'

  avg = (Ixx + Iyy)/2
  diff = (Ixx - Iyy)/2      # signed
  I1 = avg + sqrt(diff**2 + Ixy**2)
  I2 = avg - sqrt(diff**2 + Ixy**2)
  theta = atan2(-Ixy, diff)/2
  return I1, I2, theta

Looks like I was careless with the (I yyI xx) term and got it backward in the expression for diff, doesn’t it? Also, there seems to be a stray negative sign in the expression for theta. But the principal function does work despite these apparent errors. What we’re running into is the sometimes vexing difference between math and computation.

First, in the formulas for I 1 and I 2, the diff term gets squared, so flipping its sign doesn’t matter. Second, the numerical calculation of the arctangent isn’t as straightforward as you might think.

There are two arctangent functions in Python’s math library (and in the libraries of many languages):

We can’t use atan in our code because it isn’t robust for some inputs. If we tried

python:
theta = atan(2*Ixy/(Iyy - Ixx))/2

as our formula suggests, we’d get divide-by-zero errors whenever I xx=I yy. We can’t have that because there are real cross sections of practical importance for which that’s the case. Any equal-legged angle, for example.

Equal-legged angle

But atan2 can be a problem, too, because we need to distinguish between the major and minor principal axes. In particular, I decided that theta should be the angle between the x axis and the major principal axis. Using atan2 directly from the formula like this

python:
theta = atan2(2*Ixy, Iyy - Ixx)/2

can return an angle 90° away from what we want.

Using the inertia function developed earlier, the moments and product of inertia of the equal-legged angle we just looked at are

Ixx = 9.4405
Iyy = 9.4405
Ixy = -5.1429

Plopping these numbers into the naive formula above, we get

theta = -0.7854

or -45°. This is the angle from the x axis to the weak axis, not the strong axis. The correct answer is 45°, just like the blue line in the figure.

To figure out a way around this problem, let’s plot I ξξ for the four cases of interest:

  1. I xyUnknown character0andI yyUnknown characterI xx
  2. I xyUnknown character0andI yyUnknown characterI xx
  3. I xyUnknown character0andI yyUnknown characterI xx
  4. I xyUnknown character0andI yyUnknown characterI xx

This will let us see what we need for all four quadrants of the atan2 function.

Quadrants

In each of the subplots, successive peaks and valleys of I ξξ are 90° apart.

We’re looking for the maximum values of I ξξ that are closest to θ=0, which I’ve marked with the red dots. That means

  1. When I xyUnknown character0andI yyUnknown characterI xx (upper right), we want the negative θ with an absolute value greater than 45°.
  2. When I xyUnknown character0andI yyUnknown characterI xx (upper left), we want the negative θ with an absolute value less than 45°.
  3. When I xyUnknown character0andI yyUnknown characterI xx (lower left), we want the positive θ with an absolute value less than 45°.
  4. When I xyUnknown character0andI yyUnknown characterI xx (lower right), we want the positive θ with an absolute value greater than 45°.

The invocation of atan2 that gives us all of these is

python:
theta = atan2(-2*Ixy, Ixx - Iyy)/2

which we can visualize this way, where the curved arrows represent the angle 2θ for each type of result:

atan2 results

By flipping the signs of both arguments of atan2, we get the sign and magnitude of theta we’re looking for. Note that the expression used in the principal function,

python:
theta = atan2(-Ixy, diff)/2

is equivalent to

python:
theta =  atan2(-2*Ixy, Ixx - Iyy)/2

because of the way we defined diff. And by flipping the signs of both the numerator and denominator, we’re not changing the quotient or the definition of θ. We’re just choosing which solution of

tan2θ=2I xyI yyI xx

is the most useful.

If you’re mathematically inclined, you may recognize the rotation of axes as a tensor transformation and the determination of principal moments of inertia and principal directions as a eigenvalue/eigenvector problem. But writing principal in those terms would have required me to use more libraries than just math. The formulas in principal are simple, even if their derivation can take us all over the map.

Now that we’ve figured out how principal works, what good is it? It can be shown4 that when the loads on a beam are aligned with one of the principal directions, the beam will bend in that direction only. If the loading is not aligned with a principal direction, the beam will bend both in the direction of the load and in a direction perpendicular to it.

For example, if we were using the equal-legged angle above as a beam and hung a vertical downward load off of it, it would bend both downward and to the left. Not the most intuitively obvious result, but true nonetheless.

Everyone who takes an advanced strength of materials class learns the formulas for the principal moments of inertia and their directions, but there’s usually a bit of hand waving to make the math go faster. And, because the strong and weak directions are typically easy to determine by inspection, the details of picking out the correct arctangent value aren’t discussed. But there’s a richness to even the simplest mechanics, I enjoy exploring it. And since computers can’t figure things out by inspection, you can’t gloss over the details when writing a program.


  1. In case you don’t recognize them, the Greek letters ξ and η are xi and eta, respectively. They’re often used for coordinate directions when x and y are already taken. You’re probably more familiar with theta, θ, usually the first choice to represent an angle. 

  2. Don’t believe it? Well, I told you it was non-obvious. But go ahead and multiply out the right hand side and see for yourself. 

  3. Pay close attention to the negative signs. 

  4. Don’t worry, I’m not going to show it (not here, anyway). We’re almost done.