Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1776
| From | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Venn diagrams? |
| Date | 2011-04-19 10:58 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <iojprt$i78$1@smc.vnet.net> (permalink) |
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
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Venn diagrams? DrMajorBob <btreat1@austin.rr.com> - 2011-04-19 10:58 +0000
csiph-web