## Cut out circle out of circle

8

In the documentation of FilledCurve, one can create a circle "cut-out" of a bigger circle using FilledCurve and Beziercurve. Is it also possible using two Circle commands and some Boolean operator, as can be done with Adobe Illustrator using the Pathfinder commands? Does some counterpart exist in Mathematica?

Edit: As asked in the comments: there exist a few Pathfinder operations, the most kwown are

• Substract one graphic from the oterh
• Union of two graphics
• "Exclusive" union of two graphics (without intersection)
• Intersection of two graphics

Thanks for all inputs!

I don't think so, but you can make your own circle based on Bezier curves and use that. – Szabolcs – 2013-11-30T17:08:38.503

1

There is a problem with Circle or Disc and one way I can think of would be to use image processing functions. As showed here: intersecting graphics, about Polygons I highly recommend PolygonIntersection which is also described there. At the end there is IMTEK MM suplement introduced by Szabolcs in the same Q&A which might be something what you need.

– Kuba – 2013-11-30T17:28:23.200

1In the November 2011 video referenced in the linked question in Kuba's comment above, Chris Carlson refers to the forthcoming Mathematica version 9 release as containing "polygon boolean operations, differences, unions, intersections, and so forth ...". So there's a possibility that in version 10 there may be a debugged and reliable set of geometry Boolean functions... :) – cormullion – 2013-11-30T18:08:58.573

4

Perhaps Disk is more appropriate than Circle, if you want it to be filled:

Graphics[{Black, Disk[{0, 0}, 3], White, Disk[{0, 0}, 2]}] I don't think this works the same way as pathfinder, but it is getting at similar effects. One of the main reasons for using pathfinder is that it joins the multiple paths together in order to create a single object that is easy to manipulate. In Mathematica it might be more common to give the object a name and then use that name whenever you wish to reproduce, move, or modify the object.

As an example with circles (rather than disks), consider:

doubleCircle[{x_, y_}] := {Black, Circle[{x, y}, 3], Circle[{x, y}, 2]}


which creates a double circle'' function. You can draw lots of such objects:

rand = RandomInteger[{1, 15}, {5, 2}]
Graphics[doubleCircle[#] & /@ rand] 4

You can use region functionality and do boolean operations, e.g. (borrowing from bills):

annulus[c_, r1_, r2_] := RegionDifference[Disk[c, r1], Disk[c, r2]]
fun[] := Module[{rand}, rand = RandomInteger[{1, 15}, {5, 2}];
RegionPlot[RegionUnion @@ (annulus[#, 3, 2] & /@ rand),
AspectRatio -> Automatic, PlotStyle -> Red,
BoundaryStyle -> {Thickness[0.01], Yellow}, Background -> Black,
Frame -> None, PlotRange -> {{-5, 20}, {-5, 20}},
PlotPoints -> 40]]


The following animation is made from tab=Table[fun[],20]: 2

You can control the thickness in this way.

Graphics[{Thickness[#], Circle[{0, 0}, 3]}] & /@ {0.1, 0.2, 0.3} 