[metapost] Intersection of sets
Hartmut Henkel
hartmut_henkel at gmx.de
Sat Oct 31 17:21:36 CET 2009
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
More information about the metapost
mailing list