3
$\begingroup$

Suppose I have a big circle and a series of small circle.

big = Circle[{0, 0}, 10];
smalls = Circle[{-5, -5}, #] & /@ Range[1, 5, 0.2];
Graphics[{big, smalls}]

enter image description here

For the small circles, I only want to show those line within the big circle, namely, using the big circle to trim the small circles. Are there some effective ways?

$\endgroup$
  • $\begingroup$ Take a look at RegionIntersection and friends. $\endgroup$ – Kuba Jan 29 '18 at 12:52
  • $\begingroup$ I know RegionIntersection can do this. But I have to convey the curve to the region. Is there a direct method? $\endgroup$ – Ice0cean Jan 29 '18 at 12:55
9
$\begingroup$

Here are a couple possibilities:

$1$. Use Texture:

Graphics[
    {
    Texture[Graphics[{smalls}, PlotRange->{{-10,10},{-10,10}}]],
    EdgeForm[Black],
    Polygon[
        CirclePoints[{0,0}, 10, 120],
        VertexTextureCoordinates -> Rescale[CirclePoints[{0,0},10,120], {-10,10}]
    ]
    }
]

enter image description here

$2$. Use ImageMultiply:

ImageMultiply[
    Graphics[smalls, PlotRange->{{-10,10},{-10,10}}],
    Graphics[{White, EdgeForm[Black], Disk[{0,0},10]}, Background->None]
]

enter image description here

(Addendum)

$3$. And one more possibility:

Graphics[{
    RegionIntersection[Disk[{0,0},10],#]& /@ smalls,
    big
}]

enter image description here

$\endgroup$
3
$\begingroup$

Using ContourPlot with RegionFunction

eqns = {x^2 + y^2 == 100, 
    Thread[(x + 5)^2 + (y + 5)^2 == Range[1, 5, 1/5]^2]} // Flatten;

ContourPlot[Evaluate@eqns, {x, -10, 10}, {y, -10, 10},
 RegionFunction -> Function[{x, y}, x^2 + y^2 <= 100],
 Frame -> False]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.