MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Venn diagrams?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118259] Re: Venn diagrams?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 18 Apr 2011 06:50:23 -0400 (EDT)

venn[
   area1_?Positive, 
   area2_?Positive, 
   overlap_?NonNegative ] /;
  overlap <= Min[area1, area2] :=
 Module[{area, m, x2,
   r1 = Sqrt[area1/Pi],
   r2 = Sqrt[area2/Pi]},
  m = Max[r1, r2];
  area[x0_?NumericQ] :=
   NIntegrate[
    Boole[x^2 + y^2 <= r1^2 && 
      (x0 - x)^2 + y^2 <= r2^2],
    {x, -r1, r1}, {y, -m, m}];
  x2 = If[overlap == 0,
    r1 + r2,
    If[overlap == Min[area1, area2],
     r1 - r2,
     Chop[x0 /.
       FindRoot[area[x0] == overlap,
        {x0, r1}]]]];
  Graphics[{
    Red, Circle[{0, 0}, r1],
    Blue, Circle[{x2, 0}, r2]}]]

venn[5, 3, 1]


Bob Hanlon

---- dantimatter <google at dantimatter.com> wrote: 

=============

Hey Everyone,
Is there a nice and easy way to make pretty Venn diagrams with
Mathematica, where the areas of the circles and intersecting regions
are to scale?
Cheers
Dan




  • Prev by Date: Re: Solve vs. nonlinearity
  • Next by Date: Re: SortBy + Sort Strings with apo.marks + CharacterCode
  • Previous by thread: Re: Venn diagrams?
  • Next by thread: Re: Venn diagrams?