Drawing Regular Polygons
This macro will draw a regular polygon with any number of sides, and with inscribed and circumscribed circles.
DEFINE A_polygon_macro
LOCAL P
LOCAL D
LOCAL N
LOCAL R
LOCAL A
LOCAL P1
LOCAL P2
LOCAL Pm
LOOP
READ 'Pick the center point of the polygon' P
READ 'Enter the diameter of the circumscribing circle' D
READ 'Enter the number of sides in the polygon ' N
LET R (D/2)
LET A ((180-(360/N))/2)
LET P1 (P+PNT_XY(R*COS A)(R*SIN A))
LET P2 (P+PNT_XY(-R*COS A)(R*SIN A))
LET Pm ((P1 + P2) /2)
LINE P1 P2
MODIFY Pm ROTATE COPY (N -1) CENTER P (360/N)
CIRCLE P (R*SIN A)
CIRCLE P R
WINDOW FIT
END_LOOP
END_DEFINE
Parent topic