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?
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
// 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]);