Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #1776 > unrolled thread

Re: Venn diagrams?

Started byDrMajorBob <btreat1@austin.rr.com>
First post2011-04-19 10:58 +0000
Last post2011-04-19 10:58 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Venn diagrams? DrMajorBob <btreat1@austin.rr.com> - 2011-04-19 10:58 +0000

#1776 — Re: Venn diagrams?

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-04-19 10:58 +0000
SubjectRe: Venn diagrams?
Message-ID<iojprt$i78$1@smc.vnet.net>
This is 700 times faster at my machine:

Clear[area, d, r1, r2, venn]
area[r1_, r2_,
    d_] = -(1/2)
       Sqrt[(d + r1 - r2) (d - r1 + r2) (-d + r1 + r2) (d + r1 + r2)] +
     r1^2 ArcCos[(d^2 + r1^2 - r2^2)/(2 d r1)] +
    r2^2 ArcCos[(d^2 - r1^2 + r2^2)/(2 d r2)];
venn[area1_?Positive, area2_?Positive, overlap_?NonNegative] /;
   overlap <= Min[area1, area2] :=
  Module[{x2, r1 = Sqrt[area1/Pi], r2 = Sqrt[area2/Pi], d},
   d = Which[overlap == 0, r1 + r2,
     overlap == Min[area1, area2], r1 - r2,
     True, Chop[d /. FindRoot[area[r1, r2, d] == overlap, {d, r1}]]];
   Graphics[{Red, Circle[{0, 0}, r1], Blue, Circle[{d, 0}, r2]}]]
venn[5, 3, 1]

http://mathworld.wolfram.com/Circle-CircleIntersection.html

Bobby

On Mon, 18 Apr 2011 05:50:23 -0500, Bob Hanlon <hanlonr@cox.net> wrote:

>
> 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@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
>
>
>


-- 
DrMajorBob@yahoo.com

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web