Post Reply 
Any Surveyors?
06-17-2014, 01:30 AM
Post: #13
RE: Any Surveyors?
(06-16-2014 02:49 PM)Peter Murphy Wrote:  Hi Jacob,

I'd be most interested in knowing what algorithm you use to calculate the areas of polygons with straight sides, and something about how you implement it.

For the polygon with straight sides I use the DMD method. Consider a shape with two curves for example. To calculate the initial polygon area we can just pretend that the curves are not present and instead straight lines are joining the ends instead.

[Image: AreaCalc2.png]

The DMD method works by multiplying the X-Coordinate value of a point with the Y-Coordinate value of the point following it in sequence around the perimeter. Likewise the Y-Coordinate is multiplied by the following point's X-Coordinate value. Assuming we are going in a clockwise direction joining points 1-2-4-5-7-8-9-10-1 to complete the loop. See the spreadsheet below. First take X of Point 1 and multiply by Y of Point 2 = 100, then X of Point 2 and multiply by Y of Point 4 = 225, etc. and looping back around to the first Point. Then you take the sum of all these multiplications and arrive at 2250. Next take Y of Point 1 and multiply by X of Point 2 = 150, etc. and arrive at a sum of 2750. Take one sum and subtract the other (2750-2250=500) then divide by 2 (500/2=250) which is your area in square units. The sign of the final answer indicates whether the order of calculation was done in a clockwise or counter-clockwise direction. If the direction is of no consequence simply take the absolute value. The direction is very helpful to extract here when curves are involved.

[Image: AreaCalc1.png]

As to how I implemented this, below is a simplified User RPL version of the System RPL code I use. Assume XCoords and YCoords are local variables, and are lists of the point coordinates, x and y respectively ordered by sequence. The \GSLIST command is the List summation command.

Code:
  XCoords
  YCoords
  OVER
  DUP
  TAIL
  SWAP
  HEAD
  +
  OVER
  *
  \GSLIST
  UNROT
  DUP
  TAIL
  SWAP
  HEAD
  +
  *
  \GSLIST
  -
  2.
  /

Pretty straight forward, then to calculate the segment areas of any curves and apply as necessary.

Example of how the input process works with the points stored in a database:
[Image: AreaCalc3.png]

Area is calculated and displayed:
[Image: AreaCalc4.png]

Optionally plot the polygon:
[Image: AreaCalc5.png]

Have I just confused you or does that make sense?

Jacob
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Any Surveyors? - CosmicTruth - 06-10-2014, 11:14 AM
RE: Any Surveyors? - MNH - 06-11-2014, 03:33 AM
RE: Any Surveyors? - Jacob Wall - 06-14-2014, 01:29 AM
RE: Any Surveyors? - CosmicTruth - 06-14-2014, 12:10 PM
RE: Any Surveyors? - Jacob Wall - 06-14-2014, 02:48 PM
RE: Any Surveyors? - rprosperi - 06-14-2014, 05:05 PM
RE: Any Surveyors? - CosmicTruth - 06-14-2014, 05:39 PM
RE: Any Surveyors? - Jacob Wall - 06-15-2014, 08:11 AM
RE: Any Surveyors? - HP67 - 06-16-2014, 02:56 PM
RE: Any Surveyors? - Jacob Wall - 06-17-2014, 01:46 AM
RE: Any Surveyors? - Peter Murphy - 06-15-2014, 02:38 PM
RE: Any Surveyors? - Jacob Wall - 06-15-2014, 09:01 PM
RE: Any Surveyors? - Peter Murphy - 06-16-2014, 02:49 PM
RE: Any Surveyors? - Jacob Wall - 06-17-2014 01:30 AM
RE: Any Surveyors? - Peter Murphy - 06-17-2014, 03:10 PM
RE: Any Surveyors? - Jacob Wall - 06-18-2014, 02:25 AM
RE: Any Surveyors? - Thomas Klemm - 06-17-2014, 04:16 PM
RE: Any Surveyors? - Tim Wessman - 06-17-2014, 04:35 PM
RE: Any Surveyors? - CosmicTruth - 06-17-2014, 10:11 PM
RE: Any Surveyors? - Jacob Wall - 06-18-2014, 01:45 AM
RE: Any Surveyors? - CosmicTruth - 06-23-2014, 10:28 PM
RE: Any Surveyors? - RMollov - 06-24-2014, 01:34 AM
RE: Any Surveyors? - CosmicTruth - 06-24-2014, 02:28 AM
RE: Any Surveyors? - Alex Liggett - 03-22-2016, 08:15 AM
RE: Any Surveyors? - BrendanJ - 03-22-2016, 02:25 AM
RE: Any Surveyors? - Alex Liggett - 03-22-2016, 08:19 AM
RE: Any Surveyors? - RMollov - 03-29-2016, 12:03 AM
RE: Any Surveyors? - buffalo - 03-29-2016, 12:27 PM
RE: Any Surveyors? - MNH - 03-22-2016, 03:52 PM
RE: Any Surveyors? - MNH - 03-22-2016, 06:52 PM
RE: Any Surveyors? - MNH - 03-22-2016, 07:58 PM
RE: Any Surveyors? - BrendanJ - 03-23-2016, 02:29 AM
RE: Any Surveyors? - MNH - 03-23-2016, 04:01 PM
RE: Any Surveyors? - MNH - 03-26-2016, 01:33 PM
RE: Any Surveyors? - buffalo - 03-26-2016, 02:53 PM
RE: Any Surveyors? - RMollov - 03-27-2016, 01:41 PM
RE: Any Surveyors? - buffalo - 03-27-2016, 03:02 PM
RE: Any Surveyors? - John Keith - 03-29-2016, 02:04 AM
RE: Any Surveyors? - RMollov - 03-29-2016, 02:42 AM
RE: Any Surveyors? - MNH - 03-26-2016, 11:05 PM
RE: Any Surveyors? - ls41028 - 03-27-2016, 02:18 AM
RE: Any Surveyors? - buffalo - 03-29-2016, 08:21 AM
RE: Any Surveyors? - RMollov - 03-29-2016, 09:13 AM
RE: Any Surveyors? - RMollov - 03-29-2016, 09:17 AM
RE: Any Surveyors? - buffalo - 03-29-2016, 09:22 AM
RE: Any Surveyors? - RMollov - 03-29-2016, 11:01 AM
RE: Any Surveyors? - buffalo - 03-29-2016, 11:36 AM
RE: Any Surveyors? - John Keith - 03-29-2016, 04:03 PM
RE: Any Surveyors? - buffalo - 04-05-2016, 09:27 AM
RE: Any Surveyors? - BrendanJ - 04-17-2016, 07:35 PM
RE: Any Surveyors? - BrendanJ - 04-17-2016, 07:35 PM
RE: Any Surveyors? - Brad Barton - 04-18-2016, 01:54 AM
RE: Any Surveyors? - DavidM - 04-18-2016, 02:25 AM
RE: Any Surveyors? - Brad Barton - 04-22-2016, 08:14 PM
RE: Any Surveyors? - BrendanJ - 04-18-2016, 07:18 AM



User(s) browsing this thread: 1 Guest(s)