The easiest way to do this? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: The easiest way to do this? (
/showthread.php?tid=614694)
The easiest way to do this? -
Kimble - 11.08.2016
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.
Re: The easiest way to do this? -
PrO.GameR - 11.08.2016
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(!done) SomeArray[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.