Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Green's Theorem->Does it work for ?

  1. Aug 31, 2004 #1
    Green's Theorem-->Does it work for ..?

    Hi all, i am interested in finding out the Geometrical properties of an arbitrary section, which means 2D area. Rather than having to perform manual calculations everytime, i am trying to write a program to help me with this. There is a problem however. I cannot seem to find the appropriate mathematical expressions to help me obtain the following :

    (1) Area
    (2) Centroid
    (3) Moment of Inertia

    To help make the program easier to write, i have decided that all lines drawn are straight lines, therefore eliminating the tedious curves. Hence i can easily calculate the length of each lines and sum them up to obtain the perimeter. This is possible, because i have all the co-ordinate points. Now, what about area? I have tried using the Green's Theorem for calculations, but i am not sure whether it works for sections which have a large number of co-ordinate points. Also the centroid can also be worked out using Green's Theorem, and once again, it is not known whether it works for arbitrary co-ordinates. Does it have any limitations?

    Can anyone help explain to me whether Green's Theorem is good for this application? Or does anyone have a clearer or better algorithm which i can use?

    Thanks in advance
  2. jcsd
  3. Aug 31, 2004 #2


    User Avatar
    Science Advisor

    If you are dealing with an arbitrarily shaped area, then there is no point in working with formulas: think of the region as filled with small squares and count them. Since you are using a computer, you would just use a double loop, the first loop going across the figures, say, horizontally, the inner loop going vertically. At each step determine whether the "point" is inside or outside the figure (using whatever definition of the figure you have).
    For the centroid, the basic definition should do- you can even do it inside the same loops that calculate the area: instead of just counting the points that are inside the figure, add their x and y coordinates.
  4. Sep 1, 2004 #3
    Ivy, the tricky part of your algorithm is determining whether a point is inside or outside of the figure. The way I would do that is checking for the "next line crossed" as you go horizontally; assume the beginning of the row is outside the figure, and every time you cross a line, toggle the inside-outside indicator. This is slightly complicated by the treatment of corners, the possibility of multiple lines between one sampled point and another, and by the possibility that a point falls exactly on a line or corner. Also, the algorithm isn't very accurate for certain shapes, and it has to cover and discard a lot of squares that are outside the figure.

    For more exact answers with actually LESS complication, do this:

    Put the corners of the figure in order from highest to lowest. Take the highest point and store its height (TOP); then go down the list, comparing the TOP to the list entry, until you find a list entry which is lower than TOP. Store the height of this second list entry (BOT). Determine all of the intersections between the edges of the figure and a horizontal line going through the middle of the band. You'll have to do a little algebra to do this, and make a special provision for considering edges which are vertical. For each of the intersections, determine the slope of the edge and from that determine where the edge crosses TOP and BOT (again special provision for vertical edges). Add each pair of TOP-and BOT- edge crossings to a list. Put the crossings in order from leftmost TOP crossing to rightmost TOP crossing. You now have a bunch of trapezoids or triangles (which can be treated as trapezoids with one base of zero width). Take the four points comprising the leftmost TOP crossing, the leftmost BOT crossing, the next-leftmost TOP crossing, and the next-leftmost BOT crossing, and calculate the area of the trapezoid formed by them. Also calculate the centroid of this trapezoid. Store each centroid and corresponding area in lists. Now, if you're not yet through with the TOP and BOT crossing list, go onto the next four points and do the same for that trapezoid. Be sure to skip ALL four of the first points; don't calculate the trapezoid between next-leftmost and next-next-leftmost, because that trapezoid is outside the figure. Continue until the TOP and BOT crossing-list is used up.

    Keep the TOP&BOT crossing list for later--you'll need to know the shapes of the trapezoids to calculate the moment of inertia once you find the centroid of the whole figure. Perhaps you could have some kind of end-of-this-list flag to know later when you're done with one TOP&BOT crossing list and going onto the next, or else you could store each TOP&BOT crossing list as one row of a 2-d array. You also need to keep TOP and BOT in a separate list. As for the area and centroid lists, just keep adding to them without any special provisions.

    Now, set TOP equal to BOT, use the high-to-low list to find the next point of the figure which is lower than (the new) TOP, and record the height of that point in BOT. Do exactly the same for this new band as you did for the first band, and keep on processing bands until BOT = the lowest point in the figure (finish that band then stop).

    You should now have a big list of all the trapezoid areas and centroids. Add the areas up to get the total area. Do a weighted average of centroid location--each centroid weighted by its corresponding area--to find the centroid of the entire figure (phew).

    Now that you have the centroid, you can calculate the figure's moment of inertia. Go back to each trapezoid--which you have stored in the TOP, BOT, and TOP&BOT edge crossing lists--and use calculus.

    This method assumes that no lines in the figure cross one another. If they do cross one another, you have to specify a corner-point for each crossing, and then it will work. It also assumes that no lines in the figure lie exactly on top of one another. Basically the figure has to be a valid polygon or collection of valid polygons.

    All that seemed like a lot, but it would have been a lot harder to make a simple pixel-counting technique bug-free.
  5. Sep 7, 2004 #4
    Hi Ivy and Bartholomew, thanks for replies.

    I actually used Green's theorem in a Plane to work the centroid out. The formula is CentreX = {Sum[(Xsubi + Xsubi+1)X(Xsubi*Ysubi+1-Xsubi+1*Ysubi)]}/6A, where sub means subscript, A means Area and X and Y are the X-Y co-ordinates respectively. (i dunno how to make the formula appear as it is). Anyway i would like to enquire whether Green's theorem does work for arbitrary sections, because i was "informed" that it is limited to polygons. My section is approximated by straight lines and no curves are involved, thus eliminating integrals.

    If it works, i would like to move on to Moments of Inertia. Is Green's theorem applicable to finding it? Or can i simply use I about X= Sum{square(CentreX - Xsubi)}, and similarly for I about Y?

    Last edited: Sep 7, 2004
  6. Sep 14, 2004 #5
    I don't know how you're going to find the moment of inertia without using calculus--summing by the corners as you describe can't work because what if you have ten corners all in one spot and then 1 corner across the screen from them? You wouldn't want to weight the 10 corners ten times as much as the 1 corner. I think you have to break the figure into triangles and use calculus on each triangle.
  7. Sep 14, 2004 #6
    hi bartholomew, thanks for reply. i understand how the triangles work, but am just wondering whether there is any other mathematical method suitable for this operation?

  8. Nov 20, 2010 #7
    Re: Green's Theorem-->Does it work for ..?

    hello cigarette
    i had a hw very recently to find section properties using the green's theorem by fortran. yes, the theorem is applicable to the mom. of. inertia.
    a friend has prepared a pdf document explaining this. here is the link:
    hope it'll be helpful and it's not too late..!
    Last edited by a moderator: Apr 25, 2017
  9. Nov 20, 2010 #8
    Re: Green's Theorem-->Does it work for ..?

    :) ok it's too late probably, did not notice the year
  10. Nov 21, 2010 #9


    User Avatar
    Science Advisor

    Re: Green's Theorem-->Does it work for ..?

    Hey, what's 6 years when you are solving a math problem?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook