Polygon Dual Applet
alt="Your browser understands Java but can't seem to run this applet, sorry." >
The following keys and mouse actions do interesting things:
(NOTE: you may have to click on the applet once before it will accept keyboard input)
    Left-click - move reciprocation center or vertex of either polygon
    Middle-click (or alt-click or ctrl-click) - add a vertex to primal (red) polygon, on nearest edge
    Right-click (or meta-click) - delete nearest vertex of primal (red) polygon

    '+'/'='/'i' - zoom in
    '-'/'o' - zoom out
    's' - swap primal with dual
    'c' - toggle control panel
    '3'-'9','0'-'2' - make regular polygon with 3 - 12 sides
    Shift - '1'-'9','0' - make regular polygon with 10 - 100 sides

    Arrow keys - move reciprocation center 10 pixels in direction of arrow
    Ctrl-Arrow keys - move reciprocation center 1 pixel in direction of arrow

Debugging (stuff you don't care about):
    ' ' - repaint
    'V' - cycle event debug level (output to java console window).
    'b' - toggle double buffering

Here is what's going on:
    The red polygon is your polygon, which you can edit
    (move a vertex by left-clicking and dragging,
     add a vertex by middle-clicking,
     delete a vertex by right-clicking).
    The white dot is your reciprocation center which you can move around
    by dragging with the left mouse button.

    The white circle is the reciprocation circle,
    whose radius is the geometric mean of all the distances
    to the vertices and edges.
    You can also switch among any of the following methods for choosing
    the radius:
        - Geometric median distance to verts and edges
        - Geometric mean distance to verts and edges (default)
        - sqrt(min*max distance)
        - Equalize polygon areas
        - Equalize polygon perimeters

    The green polygon is the reciprocal polygon.

    You can choose to show any or all of the following types of CGs,
    of both the polygon and its dual:
        - average of vertices
        - CG of perimeter
        - CG of area
        - Rob's CG (see below)
        - Don's CG from paper (see below)

    When showing "Don's CG from paper":
        The red and green 'f's are f(primal) and f(dual) respectively
        (as defined in the paper) assuming the reciprocation center
        is the origin.
        The yellow 'f' is their average (not very important).
        The yellow 'F' is F(primal) = f(primal) - f(dual)
        (as defined in the paper).
        The yellow 'X' is the Canonical Reciprocation Center
        as defined in the paper (i.e. the point such that if you move
        the reciprocation center to it, the red and green f's coincide).
        (Note that if the polygon
        is not convex, the Canonical Reciprocation Center is undefined
        and the 'X' calculation will give unpredictable results.)
        You can make the reciprocation center follow the Canonical
        Reciprocation Center by checking the appropriate checkbox
        in the control panel.

    When showing "Rob's CG":
        The blue lines point outward from the reciprocation center
        towards each vertex and edge of the polygon.
        The green and red dots around the circle
        are these directions normalized so that they are points on the circle.

        The green (resp. red) dot inside the circle is the average of all
        the green (resp. red) dots around the circle.
        The yellow dot is the average of the green and red dot.

        If you want the reciprocation center to automatically
        follow the yellow dot,
        set Custom CG to "p times 1/||p|| integrated over Vertices (sum)"
        (which is the same as Rob's CG) and check the
        "Follow Custom CG of CGs (yellow +)" checkbox.

Rob's algorithm: try to make the white dot coincide with the hollow yellow dot.

Alternate algorithm: try to make any green CG symbol coincide with the corresponding red CG symbol.

        
Download source code (compressed jar file contains class files and source)

Last Modified: Mon Oct 11 11:21:05 PDT 2004
Don Hatch
hatch@plunk.org
Valid HTML 4.0!
Back to Don Hatch's home page.