The easiest way to do this?
#1

So i have an array that looks like this:

Код:
new Float:SomeArray[100][3];
It is populated with point coordinates. The problem is that those points are pretty close together.

I'd like to "clean up" this array so only the points that are at least 15.0 units away from each other stay. And i would like to export those new "cleaned up" points to a new array.

Maybe this is an easy problem for some but ...



Thanks in advance.
Reply
#2

This will print those that are near each other, while removing the data if not valid, then you should go basically tape those datas into another array.
You can re-write this to write the data for you in a clean file, but I'm only here to provide a way, it's up to you to improve it.
PHP код:
for(new i;i<100;i++)
{
    new 
done;
    for(new 
j;j<i;j++) if(SomeArray[j][0]!=FLOAT_INFINITY&&VectorSize(floatabs(SomeArray[i][0]-SomeArray[j][0]),floatabs(SomeArray[i][1]-SomeArray[j][1]),floatabs(SomeArray[i][2]-SomeArray[j][2]))<15.0)
    {
          print(
"{%f,%f,%f},",SomeArray[i][0],SomeArray[i][1],SomeArray[i][2]);
          
done=1;
        break;
    }
    if(!
doneSomeArray[i][0]=SomeArray[i][1]=SomeArray[i][2]=FLOAT_INFINITY;

#define FLOAT_INFINITY (Float:0x7F800000)
Here's the infinity if you don't have it defined.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)