home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / programm / 3172 < prev    next >
Encoding:
Internet Message Format  |  1992-11-19  |  2.2 KB

  1. Xref: sparky comp.programming:3172 sci.physics:19072 sci.math:15135
  2. Newsgroups: comp.programming,sci.physics,sci.math
  3. Path: sparky!uunet!caen!nic.umass.edu!news.amherst.edu!mkrogers
  4. From: mkrogers@unix.amherst.edu (MICHAEL K ROGERS)
  5. Subject: Re: area in closed curve; similar to net work calculation
  6. Message-ID: <BxvtAH.5D0@unix.amherst.edu>
  7. Summary: Green's Theorem applied to a piecewise linear path.
  8. Sender: news@unix.amherst.edu (No News is Good News)
  9. Nntp-Posting-Host: amhux3.amherst.edu
  10. Organization: Amherst College
  11. X-Newsreader: TIN [version 1.1 PL7]
  12. Date: Tue, 17 Nov 1992 22:32:40 GMT
  13. Lines: 43
  14.  
  15. mark@hubcap.clemson.edu (Mark Smotherman) wrote:
  16. >
  17. > I want to get a reference to the first use/publication of an algorithm
  18. > to find the area within a discretized closed curve.  While CAM is the
  19. > application for which I came up with the algorithm, I later found the
  20. > same type of problem as a net work calculation for a heat engine in
  21. > a freshman physics text (figure 19-8, Sears and Zemansky, University
  22. > Physics, 4th ed., 1970, p. 271).  So I expect this algorithm has been
  23. > around for quite a while.
  24. > Given a closed curve completely described by unit movements LRUD (left,
  25. > right, up, and down), calculate the enclosed area.  The description
  26. > may be clockwise or counterclockwise and of arbitrary shape.
  27. > area = 0;
  28. > counter = ARBITRARY_VALUE;  /* makes more sense visually if it is large */
  29. >                             /* enough so that counter never goes negative */
  30. > while( moves_are_left() ){
  31. >     move = next_move();
  32. >     switch(move){
  33. >         case L:
  34. >             area = area - counter;
  35. >             break;
  36. >         case R:
  37. >             area = area + counter;
  38. >             break;
  39. >         case U:
  40. >             counter = counter + 1;
  41. >             break;
  42. >         case D:
  43. >             counter = counter - 1;
  44. >             break;
  45. >     }
  46. >     area = abs(area);
  47.  
  48. Green's Theorem implies that the path integral around the
  49. boundary of a region of  y dx  equals the area of the region
  50. (given by the double integral over the region of  dx dy ).
  51. Your algorithm does the most straightforward evaluation
  52. of the path integral  int y dx  I can think of.  Of course
  53. the algorithm may be older than Green's Theorem which was
  54. discovered about 1828.
  55.