Combine RegionDifference with Graphics

I have this 2D graphics

a1 = {-1, Sqrt[3]};
a2 = {1, Sqrt[3]};
unitCell[x_, y_] := {Black, Disk[{x, y}, 0.1], Black,
Disk[({x, y} + a1/2), 0.1], Black, Disk[({x, y} + a2/2), 0.1], Blue,
Thickness[0.001], Line[{{x, y}, {x, y} + a1/2}],
Line[{{x, y}, {x, y} + a2/2}],
Line[{{x, y} + a2/2, {x, y} + a2/2 - (a2 - a1)/2}],
Line[{{x, y} + a2/2, {x, y} + a2}],
Line[{{x, y} + a1/2, {x, y} + a1}],
Line[{{x, y} + a1/2, {x, y} + a1/2 - (a2 - a1)/2}]};
ff2=Graphics[{Table[
unitCell @@ (a1 j + a2 k), {j, -5, 5}, {k, -5, 5}]},
ImageSize -> 300, PlotRange -> {{-6, 6}, {-6, 6}}]


I would like to exclude points outside a disk of radius r (i.e. show only points inside the red or green circle as below.

This is how I did it be not working

r=2
desirdReg= RegionDifference[ff2, Disk[{0, 0}, r]];
Region[desirdReg]


it gives:

RegionDifference::reg:  is not a correctly specified region.


I would like to get something like this

• What are the definitions of unitVectA and unitVectB?
– demm
Commented Jan 3, 2022 at 11:32
• @demm they are a1 and a2, code modified. Commented Jan 3, 2022 at 11:35

I suggest using patterns and deleting the unwanted Disk and Line objects.

reg = Disk[{3/4, 0}, 2];

ff2 = {Table[unitCell @@ (a1 j + a2 k), {j, -5, 5}, {k, -5, 5}]};

Graphics[DeleteCases[
ff2, (Disk[{x_, y_}, r_] /; {x, y} \[NotElement] reg) |
(Line[{{x1_, y1_}, {x2_, y2_}}] /; ({x1, y1} \[NotElement] reg ||
{x2, y2} \[NotElement] reg)), All]]


dsk = Disk[{0, Sqrt[3]}, Sqrt[3]];

reg = RegionIntersection[DiscretizeRegion@dsk, DiscretizeGraphics[ff2]];

cropped = MeshPrimitives[reg, All];

Graphics[{AbsoluteThickness[1], AbsolutePointSize[10], cropped}]


Graphics[{First@ff2, AbsoluteThickness[3], AbsolutePointSize[7],
MapThread[{##} &, {{ Blue, Red}, Reverse@cropped}], Opacity[.5],
Green, Circle @@ dsk}, PlotRange -> 4]