GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Download
  • News
  • Community
  • Resources
  • Language Reference
  • SmallBASIC Manual

This view

  • Original page
  • New address

GeezerVison is showing smallbasic.github.io — SmallBASIC | POLYCENT

Edit History

POLYCENT

c = POLYCENT(poly)

Home > Reference > Math

returns the centroid of a polygon poly as an array. The first element contains the x- the second element contains the y-coordinate of the centroid. POLYCENT will return an empty array if the area of the polygon is zero and the centroid is undefined.

POLYCENT is based on code from the article “Centroid of a Polygon” by Gerard Bashein and Paul R. Detmer.

See DRAWPOLY for more information on how to define the polygon.

Example:

polygon = [[50,50], [100,50], [100,100], [50,100], [50,50]]

' Calculate centroid
centroid = polycent(polygon)  
print "Centroid is at: "; centroid

' Draw polygon and a circle at position of the centroid
drawpoly polygon color 12
circle centroid(0), centroid(1) , 5 color 5
Math
ABS   ABSMAX   ABSMIN   ACOS   ACOSH   ACOT   ACOTH   ACSC   ACSCH   ASEC   ASECH   ASIN   ASINH   ATAN   ATAN2   ATANH   ATN   CEIL   COS   COSH   COT   COTH   CSC   CSCH   DEG   DERIV   DETERM   DIFFEQN   EXP   EXPRSEQ   FIX   FLOOR   FRAC   INT   INTERSECT   INVERSE   LINEQN   LOG   LOG10   M3APPLY   M3IDENT   M3ROTATE   M3SCALE   M3TRANS   MAX   MIN   POLYAREA   POLYCENT   POLYEXT   POW   PTDISTLN   PTDISTSEG   PTSIGN   RAD   RND   ROOT   ROUND   SEC   SECH   SEGCOS   SEGLEN   SEGSIN   SEQ   SGN   SIN   SINH   SQR   STATMEAN   STATMEANDEV   STATMEDIAN   STATSPREADP   STATSPREADS   STATSTD   SUM   SUMSQ   TAN   TANH   TRANSPOSE  
This page was last edited on Mon, 19 Jun 2023 14:15:53 +0200 | Markdown processed with pandoc 3.1.12.1
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.