# [metapost] Intersection of sets

Steve MC Han hmc0907 at yahoo.com
Sat Oct 31 18:25:18 CET 2009

```I don't know the exact logic behind, but it works now.

Thanks a lot.
Steve

--- On Sat, 10/31/09, Hartmut Henkel <hartmut_henkel at gmx.de> wrote:

From: Hartmut Henkel <hartmut_henkel at gmx.de>
Subject: Re: [metapost] Intersection of sets
To: "Steve MC Han" <hmc0907 at yahoo.com>
Cc: "Taco Hoekwater" <taco at elvenkind.com>, metapost at tug.org
Date: Saturday, October 31, 2009, 9:21 AM

On Sat, 31 Oct 2009, Steve MC Han wrote:

> I was wondering if you could answer this question.
>
> To draw intersection of two sets, I tried this, but it didn't work.
>
> beginfig(1)
> u:=.5cm;
> p1:= fullcircle scaled 4u shifted (.2u,0);
> p2:= fullcircle scaled 6u shifted (3u,0);
> fill buildcycle(p1,p2) withcolor (0,1,1);
> draw p1;
> draw p2;
> label(btex \$A\$ etex, (-u,0));
> label(btex \$B\$ etex, (3u,0));
> endfig;
>
> Could you experts tell me what's wrong?

1st you need to declare the paths: path p[]; (maybe you have done this
already before beginfig(1)); and the left fullcircle needs to be
rotated, to "help buildcycle()" (i guess): a fullcircle is made from 4
quarters, numbered 1...4 counterclockwise, so 2 quarters 1,4 are used
from the left one, they intersect with quarters 2,3 from the right one.
Somehow (?) the number jump 4-->1 isn't liked by buildcycle(). If you
rotate the left circle by 180 deg., quarters 2,3 are used also from the
left one. Or e. g. by -90 it works as well, then quarters 1,2 used from
the left circle.

path p[];
beginfig(1)
u:=.5cm;
p1:= fullcircle rotated 180 scaled 4u shifted (.2u,0);
p2:= fullcircle scaled 6u shifted (3u,0);
fill buildcycle(p1,p2) withcolor (0,1,1);
draw p1;
draw p2;
label(btex \$A\$ etex, (-u,0));
label(btex \$B\$ etex, (3u,0));
endfig;

end

Regards, Hartmut

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/metapost/attachments/20091031/0326e7a6/attachment.html>
```