خرید بک لینک

Vote count: 0

I am trying to loop through an arraylist of Vector2(object that has an x and y coordinate) to find the smallest distance between a certain point and then remove the reference point to check around, here is how I thought of doing it:

int index = 0;
    tmpKey = verts.get(0);
    for(int i = 0; i < verts.size; i++){
        index = i;
        for(int k = 0; k < (verts.size - 1); k++){
            if(k == i)
                continue;
            index = k;
            //Distance formula
            double dist = MathFactory.distance(verts.get(index), verts.get(k));
            if(MathFactory.distance(verts.get(index), verts.get(k + 1)) < dist){
                index = k + 1;
            }else
                index = k;

        }
        tmpKey = tmpClose;
        newVerts.add(verts.removeIndex(index));
    }

However, for some reason this gives me half the points I need, NOT EVEN in order. Please help me with this it has been a problem for a couple days. Let me reexplain the problem

Problem: I need a way to loop through an arrayList of Vector2`s and find the closest point from each point and store in another arraylist.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 20 تير 1395 ساعت: 15:34

صفحه بندی