예제 #1
0
    void _computeContinuumCrowdsFields(CC_Map_Package fields, List <Location> goalLocs)
    {
        // calculate potential field (Eikonal solver)
        computePotentialField(fields, goalLocs);
        // calculate the gradient
        calculatePotentialGradientAndNormalize();
        // calculate velocity field
        calculateVelocityField();

        isDone = true;
    }
예제 #2
0
    public CC_Map_Package buildCCMapPackage(Rect r)
    {
        float[,] gt;
        Vector4[,] ft, Ct;

        int xs = (int)Math.Floor((double)r.x);
        int ys = (int)Math.Floor((double)r.y);

        int xf = (int)Math.Ceiling((double)(r.x + r.width));
        int yf = (int)Math.Ceiling((double)(r.y + r.height));

        if (xs < 0)
        {
            xs = 0;
        }
        if (xf > _mapX)
        {
            xf = _mapX;
        }
        if (ys < 0)
        {
            ys = 0;
        }
        if (yf > _mapY)
        {
            yf = _mapY;
        }

        int xdim = xf - xs;
        int ydim = yf - ys;

        gt = new float[xdim, ydim];
        ft = new Vector4[xdim, ydim];
        Ct = new Vector4[xdim, ydim];

        for (int xI = 0; xI < xdim; xI++)
        {
            for (int yI = 0; yI < ydim; yI++)
            {
                gt [xI, yI] = theMapData.getDiscomfortMap(xs + xI, ys + yI);
                ft [xI, yI] = readDataFromPoint_f(xs + xI, ys + yI);
                Ct [xI, yI] = readDataFromPoint_C(xs + xI, ys + yI);
            }
        }
        CC_Map_Package map = new CC_Map_Package(gt, ft, Ct);

        return(map);
    }
예제 #3
0
    public CCEikonalSolver(CC_Map_Package fields, List <Location> goalLocs)
    {
        f = fields.f;
        C = fields.C;
        g = fields.g;

        N = f.GetLength(0);
        M = f.GetLength(1);

        Phi  = new float[N, M];
        dPhi = new Vector2[N, M];
        v    = new Vector2[N, M];

        accepted = new bool[N, M];
        goal     = new bool[N, M];

        considered = new FastPriorityQueue <fastLocation> (N * M);

        neighbor = new fastLocation(0, 0);

        initiateEikonalSolver(fields, goalLocs);
    }
예제 #4
0
    // *************************************************************************
    // *************************************************************************

    private void EikonalSolver(CC_Map_Package fields, List <Location> goalLocs)
    {
        // start by assigning all values of potential a huge number to in-effect label them 'far'
        for (int n = 0; n < N; n++)
        {
            for (int m = 0; m < M; m++)
            {
                Phi[n, m] = Mathf.Infinity;
            }
        }

        // initiate by setting potential to 0 in the goal, and adding all goal locations to the considered list
        // goal locations will naturally become accepted nodes, as their 0-cost gives them 1st priority, and this
        // way, they are quickly added to accepted, while simultaneously propagating their lists and beginning the
        // algorithm loop
        fastLocation loc;

        foreach (Location l in goalLocs)
        {
            if (isPointValid(l.x, l.y))
            {
                Phi [l.x, l.y] = 0f;
                loc            = new fastLocation(l.x, l.y);
                markGoal(loc);
                considered.Enqueue(loc, 0f);
            }
        }

        // THE EIKONAL UPDATE LOOP
        // next, we initiate the eikonal update loop, by initiating it with each goal point as 'considered'.
        // this will check each neighbor to see if it's a valid point (EikonalLocationValidityTest==true)
        // and if so, update if necessary
        while (considered.Count > 0f)
        {
            fastLocation current = considered.Dequeue();
            EikonalUpdateFormula(current);
            markAccepted(current);
        }
    }
예제 #5
0
 void computePotentialField(CC_Map_Package fields, List <Location> goalLocs)
 {
     EikonalSolver(fields, goalLocs);
 }
예제 #6
0
 // *************************************************************************
 //    THREAD OPERATIONS
 // *************************************************************************
 public void initiateEikonalSolver(CC_Map_Package fields, List <Location> goalLocs)
 {
     var task = UnityTask.Run(() => {
         _computeContinuumCrowdsFields(fields, goalLocs);
     });
 }