Polygon meets arc

Algorithm:

Explanation

This is a thing I wrote to find the simplest polygon that is within an arc, but not outside it. It was used as a basis for showing the playable area in snygg.

The code for finding these points boils down to finding the angle distance between the points on the outer radius (called sigma in the code):

function pointsOnArc(cx, cy, inner, outer, start, end, gen_points)
{
    function point_at(angle)
    {
        var x = cx - Math.cos(angle) * outer;
        var y = cy - Math.sin(angle) * outer;
        return {x:x, y:y}
    }
 
    var sigma     = Math.PI - 2 * Math.asin(inner / outer);
    var numpoints = Math.floor((end-start) / sigma) + 1;
     
    return gen_points(sigma, point_at, start, end, numpoints);
}
where gen_points is the following algorithm (change with the radio button above):
function(sigma, point_at, start, end, numpoints)
{
    var points = [];
    for (var i = 0; i <= numpoints; ++i)
        points.push(point_at(start + (end - start) * i/numpoints));
    return points;
}