TITLE: Generating polygons with integer coordinates bounding a circle
QUESTION [10 upvotes]: I've been trying to find an algorithm to generate polygons with integer coordinates bounding a circle from the inside and outside. I searched everywhere and couldn't find anything like this. For example in the picture below we have the red circle with a given radius, and ask for polygons with 8 points, and then the algorithm should generate the blue and green polygons.

These polygons aren't exactly regular, and I don't think these polygons are uniquely defined either as there are probably different ways to "best" fit the circle. I'm not really looking for the absolute best solution for example I could try to minimize the maximum error, but that might make the problem much more complicated. Actually I tried expressing this as an integer programming problem with quadratic Diophantine inequalities but that seems to be overkill.
Is this a problem that has been already studied/solved before? Am I missing a simple method?

REPLY [3 votes]: Follows a MATHEMATICA script which based on the convex hull for a set of points in the plane, draws approximate external and internal polygons about a circle randomly located in the integer lattice.  This script can be optimized but it was left in basics for better algorithm understanding.
grids[min_, max_] := Table[If[EvenQ[i], {i, Black}, {i, Black}], {i, Ceiling[min], Floor[max], 1}]
InternalCH[p0_List, r_] := Module[{xmin = Floor[p0[[1]] - r - 5],
    xmax = Ceiling[p0[[1]] + r + 5],
    ymin = Floor[p0[[2]] - r - 5],
    ymax = Ceiling[p0[[2]] + r + 5], xsup = -10^9, xinf, ysup, yinf,i,j, p,pts = {}},
    xinf = -xsup;
    ysup = xsup;
    yinf = xinf;
    For[i = xmin, i <= xmax, i++, 
       For[j = ymin, j <= ymax, j++, p = {i, j}; 
          If[(p - p0).(p - p0) < r^2, AppendTo[pts, p]; 
            xinf = Min[xinf, i];
            xsup = Max[xsup, i]; 
            yinf = Min[yinf, j]; 
            ysup = Max[ysup, j]]]]; 
    Return[{{xinf, xsup, yinf, ysup}, pts}]
]
p0 = RandomReal[{-30, 30}, 2];
r = RandomReal[{4, 10}];
{{xinf, xsup, yinf, ysup}, pts} = InternalCH[p0, r];
{{xinfe, xsupe, yinfe, ysupe}, ptse} = InternalCH[p0, r + 1 0.9];
gr1 = ContourPlot[(x - p0[[1]])^2 + (y - p0[[2]])^2 == r^2, {x, 
xinf - 1, xsup + 1}, {y, yinf - 1, ysup + 1}, ContourStyle -> {Thick, Black}];
gr2 = RegionBoundary[ConvexHullMesh[pts, MeshCellStyle -> {Thick,Blue, Dotted}]];
re = r + 1;
gr1e = ContourPlot[(x - p0[[1]])^2 + (y - p0[[2]])^2 == re^2, {x, 
xinf - re/4, xsup + re/4}, {y, yinfe - re/4, ysupe + re/4},ContourStyle -> {Thick, Red}];
gr2e = RegionBoundary[ConvexHullMesh[ptse, MeshCellStyle -> {Thick, Red, Dotted}]];
Show[gr2e, gr2, gr1, AspectRatio -> 1, GridLines -> grids]