Environment for creative processing of text and numerical data

SURVO MM

Area of an arbitrary n-polygon

Beginning status (before activation):
   1 *
   2 *The vertices are saved as a matrix K (repeating the first one in the end).
   3 *MATRIX K ///
   4 *0 0
   5 *4 1
   6 *3 3
   7 *2 2
   8 *0 2
   9 *1 1
  10 *0 0
  11 *
  12 *Activate the following two commands:
  13 *MAT SAVE K  
  14 *MAT DIM K  
  15 *
  16 *P(x,y):=MAT_K(x,y)
  17 *Area=for(i=1)to(rowK-1)sum((P(i,1)*P(i+1,2)-P(i+1,1)*P(i,2))/2)
  18 *
  19 *Area=  
  20 *GPLOT K.MAT,1,2 / LINE=POLYGON,5 GRID=1,1 Graph of a polygon
  21 *

Ending status (after activation):
   1 *
   2 *The vertices are saved as a matrix K (repeating the first one in the end).
   3 *MATRIX K ///
   4 *0 0
   5 *4 1
   6 *3 3
   7 *2 2
   8 *0 2
   9 *1 1
  10 *0 0
  11 *
  12 *Activate the following two commands:
  13 *MAT SAVE K  
  14 *MAT DIM K /* rowK=7 colK=2
  15 *
  16 *P(x,y):=MAT_K(x,y)
  17 *Area=for(i=1)to(rowK-1)sum((P(i,1)*P(i+1,2)-P(i+1,1)*P(i,2))/2)
  18 *
  19 *Area=5.5
  20 *GPLOT K.MAT,1,2 / LINE=POLYGON,5 GRID=1,1 Graph of a polygon
  21 *

The last activation creates a graph:

Graph of a polygon  (Survo graphics window)

Home  |  News  |  Publications  |  Download  |  Flash
Copyright © Survo Systems 2001-2008. All rights reserved.
Updated 2008-10-20 by webmaster'at'survo.fi.
Best viewed with any browser.