# Add region constraint to Graphics

I would like to only show the part of Black circles within the Red circle.

Can I do that with Graphics, Circle and/or some sort of Region Constraint? step = 2 Degree;
\[Alpha] = Range[2 Degree, 80 Degree, step];
x = ConstantArray[0, Length@\[Alpha]];
y = Sec@\[Alpha];
range = 1.01;
Graphics[{Red, Circle[{0, 0}, 1], Black,
PlotRange -> {{-range, range}, {-range, range}}]


At the moment, I use ContourPlot with RegionFunction option. However, my plot contains a large number of these circles (The amount of the circles shown here is only a quarter for the current step), which makes ContourPlot approach very slow. Moreover, when I zoom in, quite often I find the circles drawn by ContourPlot are not circular, presumably due to PlotPoints and MaxRecursion etc. I tried to play with these two options, but did not succeed in terms of quality (being a circle) and speed.

Thank you!

You can use the three-argument form of Circle:

Graphics[{Red, Circle[{0, 0}, 1], Black,
MapThread[Circle[{#1, #2}, #3, {π + ArcTan[#3], 2 π - ArcTan[#3]}] &,
PlotRange -> {{-range, range}, {-range, range}}] Alternatively, use RegionIntersection with Disk[] to get the needed portions of black circles:

circles = MapThread[Circle[{#1, #2}, #3] &, {x, y, radius}];

circles2 = RegionIntersection[Disk[], #] & /@ N[circles];

Graphics[{Red, Circle[{0, 0}, 1], Black,  circles2},
PlotRange -> {{-range, range}, {-range, range}}]


same picture

Update: An alternative way to hide unwanted portions of circles using FilledCurve:

filledCurve = FilledCurve[{{Line[Append[#, First @ #]& @
CirclePoints[range Sqrt @2, 4]]},
{Line[Append[#, First @ #]& @ CirclePoints]}}];

Graphics[{Red, Circle[{0, 0}, 1], Black,  circles,
EdgeForm[None], White, filledCurve},
PlotRange -> {{-range, range}, {-range, range}}]


same picture as above

• I used the 1st method of yours, which is the fastest among all the provided answers at the moment. But it seems the ArcTan[#3 Sqrt[1/(1 + #3^2)] Sqrt[1 + #3^2]] can be shortened to ArcTan[#3]. Also, the center of the circles lies along the y axis, which is a special case. I wonder what this method could be if the center of the circle is arbitrary. Could you please elaborate if possible? Thanks. I realized that for the "arbitrary center" case, it requires the actual information of the circle, and therefore, it maybe changes from case to case. – Bemtevi77 Jul 14 '19 at 6:33
• @Bemtevi77, updated with the simpler form. Re arbitrary centers, I think the second and third methods should work as is. I think the first method should also work but I am not sure. – kglr Jul 14 '19 at 6:42
g = Graphics[{Red, Circle[{0, 0}, 1], Black, 