Don "Quixote" Eisele's page of Campaign Cartographer stuff

Drawing a Polygon by Area

I wanted to mess around with geometric dissections, so here's a way to draw a regular polygon based on the area (so you can get two polygons with the same area, but different shapes).

This requires the SQRT Macro, also on this site.

The .mac file for direct download

Usage:
APoly

or:
GV varAPolyArea 25
GV varAPolyNumsides 7
GV varAPolyRot 12
GP varAPolyOrigin 0,0
APolyFixed


// Commented source.  don't just cut/paste this, download the .mac file directly

// this part just enters in area, number of sides, rotation, etc
MACRO APoly
ECOFF
SELSAVE
GV varAPolyArea 20
GV varAPolyArea ^DEnter area of polygon: (20)
GV varAPolyNumsides 4
GV varAPolyNumsides ^DEnter number of sides of Polygon: (4)
GV varAPolyRot 0
GV varAPolyRot ^DEnter rotation of polygon: (0)
GP varAPolyOrigin 0,0
GP varAPolyOrigin ^DCenter of polygon (0,0):
APolyFixed
SELREST
ECON
ENDM


// calculate and draw the polygon
// if you break up a polygon into triangles by drawing lines from the
// center to each vertex, you can use trigonometry to find that
// the area of each triangle is:
//    r^2 * sin(180/n) * cos(180/n)
// where n is the number of sides of the polygon
// so the area of the entire polygon will be that times n
// solving for the radius:
//   r = sqrt(Area/ ( n*sin(180/n)*cos(180/n) ) )
MACRO APolyFixed
GSIN varAPolySin (180/varAPolyNumsides)
GCOS varAPolyCos (180/varAPolyNumsides)
GV varAPolyRadsq (varAPolyArea/(varAPolyNumsides*varAPolySin*varAPolyCos))
GV varSQRT varAPolyRadsq
SQRT
GV varAPolyRad varSQRT
GP varAPoly2Point ref varAPolyOrigin