I manage to create a circle inside triangle with this code, but circle inside other polygons are not maximum size:

var p1 = board.create("point", [0.0, 2.0]);
var p2 = board.create("point", [2.0, 1.0]);

//var pol = board.create("regularpolygon", [p1, p2, 3]);
var pol = board.create("regularpolygon", [p1, p2, 4]);
//var pol = board.create("regularpolygon", [p1, p2, 5]);

board.create("incircle", pol.vertices);

What is the easiest way to draw a maximum circle inside square and pentagon?

How about smallest circle around the polygon?

  • this question should be on stackoverflow.
    – john-jones
    Commented Sep 27, 2013 at 14:12
  • Yea, I realized it later, but on the other hand John gave a good answer for it. I'm happy either way, solutions given in general way to a specific problem, or specific example given to a general problem. Anything can help.
    – MarkokraM
    Commented Oct 1, 2013 at 6:22

2 Answers 2


This is why geometry class in high school had you spending all that time drawing stuff.

Assuming a regular polygon (all sides same length, all "corners" same angle), it is immediately obvious that the centers of the largest inscribed circle and the smallest circumscribed circle are identical, and are given by the vector arithmetic mean of the polygon vertices.

The largest inscribed circle touches the polygon at the midpoint of each edge. The radius is thus given by the distance from the center to the midpoint of any one edge of the polygon.

The smallest circumscribed circle touches the polygon at every vertex. The radius is the distance from the center to any one vertex of the polygon.

  • +1 and "good on you" for explaining the solution rather than giving code. Commented Sep 26, 2013 at 9:59
// two points for the side of the polygon
var p1 = board.create("point", [0.0, 0.0], point_props);
var p2 = board.create("point", [4.0, 0.0], point_props);

// square polygon has 4 regular sides
var pl = board.create("regularpolygon", [p1, p2, 4]);

// center point of the polygon
var cp = board.create("circumcenter", pl.vertices);

// for incircle get middle point of the side
var mp = board.create("midpoint", [p1, p2]);
board.create("circle", [cp, mp]);

// for outcircle use either p1 or p2
board.create("circle", [cp, p1]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.