17.6.10

weighted straight skeleton source release


The straight skeleton shrinks in the boundary of a polygon, whilst tracing out the corners to create a roof-like structure. Thus is quite useful for building things like roofs or offset surfaces. I never did find an impelmentation that wasn't CGAL's, so here's a floating point implementation.

rect26802

The weighted skeleton allows the edges to move at different speeds. You could even assign negative weights to edges.



Instructions: (java webstart, binary code, run at your own risk).
  • Left drag the little orange squares at the corners of the cross
  • Right drag to move the view
  • To change the weights drag the big orange circles
  • Control-click to add corners
  • Shift-click to remove corners
  • There are known bugs (for example the polygons in the UI overlap, there will be cases where it doesn't tessellate).
  • Use alt-while-dragging to snap to grid
Google code project (java) is here.

Here's an example of how to skeleton a simple triangle. Points are defined counter clockwise. If you only want the 2d projection, discard the final (z) co-ordinate of the output-faces.

        Corner
        c1 = new Corner ( 0,0),
        c2 = new Corner (100,-100 ),
        c3 = new Corner (100,0 );
      
       Machine directionMachine = new Machine ();
      
       loop1.append(new Edge ( c1,c2 ) );
       loop1.append(new Edge ( c2, c3 ) );
       loop1.append(new Edge ( c3, c1 ) );
      
       for (Edge e : loop1)
        e.machine = directionMachine;
      
      
       Skeleton skel = new Skeleton (out, true);
       skel.skeleton();
      
       for ( Face face : skel.output.faces.values() )
       {
           System.out.println("face:");
           for (Loop  lp3 : face.points)
            for (Point3d pt : lp3)
             System.out.println(pt);
       }