示例#1
0
    public static Edge createBisectingEdge(Site site0,Site site1)
    {
        float dx,dy,absdx,absdy;
        float a,b,c;
        dx=site1.x-site0.x;
        dy=site1.y-site0.y;
        absdx=dx>0?dx:-dx;
        absdy=dy>0?dy:-dy;
        c=site0.x*dx+site0.y*dy+(dx*dx+dy*dy)*0.5;
        if (absdx > absdy)
        {
            a = 1.0; b = dy/dx; c /= dx;
        }
        else
        {
            b = 1.0; a = dx/dy; c /= dy;
        }
        Edge edge=Edge.create();
        edge.leftSite = site0;
        edge.rightSite = site1;
        site0.addEdge(edge);
        site1.addEdge(edge);

        edge._leftVertex = null;
        edge._rightVertex = null;

        edge.a = a; edge.b = b; edge.c = c;
        //trace("createBisectingEdge: a ", edge.a, "b", edge.b, "c", edge.c);

        return edge;
    }