September 16, 2008

Venn diagrams in PIC



For the true nerds: some simple PIC macros for creating Venn diagrams (of the 1, 2 or 3 set variety):
define vennDiagram1 {
    box height $1 width $2
    $3 at last box.nw - (0.1, 0.0)
    "U" at last box.ne - (0.1, 0.1)
    circle radius last box.height/4 at last box.c
    $4 at last circle.nw + (-0.1, 0.1)
    move to last box.e
}

define vennDiagram2 {
    box height $1 width $2
    $3 at last box.nw - (0.1, 0.0)
    "U" at last box.ne - (0.1, 0.1)
    circle radius last box.height/4 at last box.c - (last box.height/8, 0)
    $4 at last circle.nw + (-0.1, 0.1)
    circle radius last box.height/4 at last box.c + (last box.height/8, 0)
    $5 at last circle.ne + (0.1, 0.1)
    move to last box.e
}

define vennDiagram3 {
    box height $1 width $2
    $3 at last box.nw - (0.1, 0.0)
    "U" at last box.ne - (0.1, 0.1)
    circle radius last box.height/4 at last box.c - (last box.height/7, -last box.height/10)
    $4 at last circle.nw + (-0.1, 0.1)
    circle radius last box.height/4 at last box.c + (last box.height/7, last box.height/10)
    $5 at last circle.ne + (0.1, 0.1)
    circle radius last box.height/4 at last box.c - (0, last box.height/7)
    $6 at last circle.sw - (0.1, 0.1)
    move to last box.e
} 

No comments: