Exemplo n.º 1
0
    private VornoiEvent CalcEdgeEvents(Parabola parabola)
    {
        Parabola leftParabola  = (Parabola)_linkedList.First((p) => p is Parabola && p != parabola && parabola.Focus.x > (p as Parabola).Focus.x);
        Parabola rightParabola = (Parabola)_linkedList.First((p) => p is Parabola && p != parabola && parabola.Focus.x <= (p as Parabola).Focus.x);
        var      node          = _linkedList.Find(parabola);
        HalfEdge leftEdge      = node.Next.Value as HalfEdge;
        HalfEdge rightEdge     = node.Previous.Value as HalfEdge;

        if ((leftParabola == null) || (rightParabola == null) || (leftParabola.Focus == rightParabola.Focus))
        {
            return(null);
        }

        var crosspoint = leftEdge.IntersectionPoint(rightEdge);

        if (crosspoint == null)
        {
            return(null);
        }

        float distance = Vector2.Distance(crosspoint, parabola.Focus);

        if (crosspoint.y + distance > Ypos)
        {
            return(null);
        }

        return(new EdgeEvent(parabola)
        {
            Order = crosspoint.y + distance
        });
    }