home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.programming:3066 sci.physics:18154 sci.math:14413
- Newsgroups: comp.programming,sci.physics,sci.math
- Path: sparky!uunet!gatech!hubcap!mark
- From: mark@hubcap.clemson.edu (Mark Smotherman)
- Subject: area in closed curve; similar to net work calculation
- Message-ID: <1992Nov5.132626.21379@hubcap.clemson.edu>
- Organization: Clemson University
- Date: Thu, 5 Nov 1992 13:26:26 GMT
- Lines: 41
-
-
- I want to get a reference to the first use/publication of an algorithm
- to find the area within a discretized closed curve. While CAM is the
- application for which I came up with the algorithm, I later found the
- same type of problem as a net work calculation for a heat engine in
- a freshman physics text (figure 19-8, Sears and Zemansky, University
- Physics, 4th ed., 1970, p. 271). So I expect this algorithm has been
- around for quite a while.
-
- Given a closed curve completely described by unit movements LRUD (left,
- right, up, and down), calculate the enclosed area. The description
- may be clockwise or counterclockwise and of arbitrary shape.
-
-
- area = 0;
- counter = ARBITRARY_VALUE; /* makes more sense visually if it is large */
- /* enough so that counter never goes negative */
- while( moves_are_left() ){
- move = next_move();
- switch(move){
- case L:
- area = area - counter;
- break;
- case R:
- area = area + counter;
- break;
- case U:
- counter = counter + 1;
- break;
- case D:
- counter = counter - 1;
- break;
- }
- area = abs(area);
-
-
- Please email me directly. I don't regularly read some of the cross-posted
- groups. Thanks.
- --
- Mark Smotherman, CS Dept., Clemson University, Clemson, SC 29634-1906
- (803) 656-5878, mark@cs.clemson.edu or mark@hubcap.clemson.edu
-