Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: Green's theorem in matlab? Date: Mon, 16 Aug 2010 07:21:06 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 20 Message-ID: <i4aot2$3sb$1@fred.mathworks.com> References: <i4ajm5$4vl$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-03-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1281943266 3979 172.30.248.38 (16 Aug 2010 07:21:06 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Mon, 16 Aug 2010 07:21:06 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:662284 "Ray Goldman" <kmmansory@yahoo.com> wrote in message <i4ajm5$4vl$1@fred.mathworks.com>... > hey guys > I posted a message a couple of weeks ago about calculating the area inside a closed curve, well, some guys gave me this formula: > area = 1/2*abs(sum(X.*Y([2:end,1])-Y.*X([2:end,1]))); > and it works perfectly, so thanks very much whoever did, sorry I don't remember their name now, I think it's Roger. However, according to my tutor, apparently, I have to explain where I got this formula from in my report. I know it's Green theorem, but I have been searching since and I have got no where on relating it to Green's theorem. now the deadline is tomorrow. so can somebody please just give me a simple explanation how to get from Green's theorem to this numerical representation, I know I'm asking a lot but please just an outline or anything and I'll owe you forever but I'm really desperate right now, thanks guys so much. > Ray - - - - - - - - - - - - I gave you that formula, Ray. Green's theorem is one way, but I think there's an easier way of demonstrating it. Suppose P1 = (x1,y1) and P2 = (x2,y2) are two successive points along a closed polygon as you travel counterclockwise around it. The area of the triangle P1P2O where O is the origin is well known to be one half the cross product of the two vectors pointing from O to P1 and O to P2, and is itself a vector pointing straight up along the z-axis if we are allowing the introduction of a third dimension temporarily. This half cross product is simply (x1*y2-y1*x2)/2. If it is positive that means going P1 to P2 to O and to P1 is counterclockwise. With a negative value it is in the other direction. If you add up all the triangles's areas you will get the expression I gave you. If the polygon surrounds the origin then what you have is clearly the polygon's area (if traveling in a counterclockwise direction.) If the origin lies outside the polygon, notice that the triangles' portions that lie outside the polygon are eventually all cancelled out by other triangles returning on the other side of the polygon with negative area values leaving only the area of the polygon itself. It's easier to draw a picture than to put it into words. So draw a picture and see how it works. For Green's theorem look up the Wikipedia site at http://en.wikipedia.org/wiki/Green's_theorem at the first equation. Set functions M = x/2 and L = -y/2 and calculate the line integral going along a line segment from P1 to P2 and get, lo and behold, (x1*y2-y1*x2)/2 (after all the smoke clears away.) Adding these all up gives the closed line integral on the left side of that equation. With the given M and L the integral on the right side is simply the double integral over the area of the polygon of the quantity 1/2 - (-1/2) = 1, so it's just the polygon's area itself. QED You should realize that Green's theorem as applied here is just a flat two-dimensional version of Stoke's theorem where the vector field has a component of x/2 in the y-axis direction and -y/2 in the direction of the x-axis. The area integral of the curl of this field over the interior of the polygon is simply the integral of 1 over that area and the line integral around the polygon boundary is Stoke's theorem line integral. Roger Stafford