I am trying to get the union of four circles in asymptote:
unitsize(1mm);
import graph;
pair o1 = (0, 0);
pair o2 = (10, 0);
pair o3 = (10, 10);
pair o4 = (0, 10);
path c1 = Circle(o1, 10);
path c2 = Circle(o2, 10);
path c3 = Circle(o3, 10);
path c4 = Circle(o4, 10);
draw(c1^^c2^^c3^^c4, black);
Apparently this is not the right way:
Using inkscape I can get the desired effect:
@g.kov 's answer partially solves the problem, but if the paths are not consecutively intersecting, then buildcycle
will not work:
unitsize(1mm);
import graph;
pair o1 = (0, 0);
pair o2 = (10, 0);
pair o3 = (10, 10);
pair o4 = (0, 10);
path c1 = Circle(o1, 8);
path c2 = Circle(o2, 8);
path c3 = Circle(o3, 1);
path c4 = Circle(o4, 1);
guide[] gg=c1^^c2^^c3^^c4;
guide g=gg[0];
for(int i=1;i<gg.length;++i){
g=buildcycle(g,gg[i]);
}
draw(g,black);
This outputs nothing, while what I wanted is this (output from inkscape):
The reason I am checking out asymptote is that it's a programming language and should be much more powerful when the number of paths increase to a higher order.
buildcycle
andintersection
intersection
:Return all (unless there are infinitely many) intersection times of paths p and q as a sorted array of real arrays of length 2
, what isintersection times
?