Message Boards Message Boards

6
|
8476 Views
|
1 Reply
|
9 Total Likes
View groups...
Share
Share this post:

Venn 5 diagram

Posted 6 years ago

Code for a nice Venn 5.

venn5

pp=RootReduce[2CirclePoints[5]/(EuclideanDistance@@CirclePoints[5][[{1,2}]])];
sp=Join[Table[2.12CirclePoints[10][[Mod[n-2,10,1]]]+pp[[2]],{n,1,9}],
Table[1.05CirclePoints[10][[Mod[n-6,10,1]]]+pp[[4]],{n,1,7}]];
Graphics[{AbsoluteThickness[2],Table[BSplineCurve[sp.RotationMatrix[2 k Pi/5], SplineClosed-> True],{k,0,4}]},ImageSize->600]
POSTED BY: Ed Pegg

Hey Ed, I wanted to color your figure such that color classes correspond to the number of intersecting sets. The below code works (for any set of closed curves), however, it uses meshes which feels imprecise. Even for the 3 circle case one can see mesh artifacts. Whats the most natural way to do this? Would you generate the bounding (piecewise) curve for each region and assemble the figure that way, like a tiling?

(*recreate booleanregion(buggy). zo_list is a 0,1 list (or list of \
lists) of region indicators*)
booregion[regs_List, zo_List] := (
  If [Depth[zo] == 2,
   If[Total[zo] == Length[zo], out = EmptyRegion[2], 
    out = RegionUnion[Pick[regs, zo, 0]]]; 
   RegionDifference[RegionIntersection[Pick[regs, zo, 1]], out],
   RegionUnion[booregion[regs, #] & /@ zo]
   ]
  )

(*generate weight k binary vectors of length n*)
class[n_Integer, k_Integer] := 
 ReplacePart[ConstantArray[0, n], Thread[# -> 1]] & /@ 
  Subsets[Range[n], {k}]

vennplot[regs_List, colors_List] := (
  len = Length[regs];
  Graphics@
   Riffle[colors[[;; len]], 
    Table[booregion[regs, class[len, i]], {i, 1, len}]])

(*sp is defined in the original post*)
regs = Table[
   DiscretizeGraphics[
    FilledCurve@
     BSplineCurve[sp.RotationMatrix[2 k Pi/5], 
      SplineClosed -> True]], {k, 0, 4}];
vennplot[regs, ColorData["TemperatureMap"] /@ Range[0, 1, .25]]

enter image description here

POSTED BY: Benjamin Shemmer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract