Get distance between 2 points. -
-=SR=- - 20.02.2011
I been trying to figure this out, and cannot think of a way to do this.
I need to get a distance between 2 points. Anybody have any idea or some suggestions on how to do this?
Thanks, SR
Re: Get distance between 2 points. -
bigcomfycouch - 20.02.2011
pawn Код:
stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 )
{
return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) ) );
}
Re: Get distance between 2 points. -
-=SR=- - 20.02.2011
thanks, gona give it a try, will post back here with results
Re: Get distance between 2 points. -
-=SR=- - 23.02.2011
It works for what I needed, thanks a lot.
Re: Get distance between 2 points. -
Stefan_Toretto - 07.03.2011
This is in meters? or Kilometers?
Re: Get distance between 2 points. -
[DRD]Rodney - 04.09.2011
I failed. wrong post.
Re: Get distance between 2 points. -
rt-2 - 02.03.2016
Quote:
Originally Posted by bigcomfycouch
pawn Код:
stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 ) { return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) ) ); }
|
Quote:
Originally Posted by -=SR=-
It works for what I needed, thanks a lot.
|
The code is actually:
Код:
pawn Код:
stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 ){ return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) );}
You had one too many ')'
Re: Get distance between 2 points. -
Sascha - 02.03.2016
Quote:
Originally Posted by blinkpnk
The code is actually:
Код:
pawn Код:
stock GetDistance( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 ){ return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) );}
You had one too many ')'
|
Not really, with 3 ) at the end you just close the "floatsqroot" function
the 4th ) closes the "floatround"
Re: Get distance between 2 points. -
rt-2 - 05.03.2016
IDK but I had to remove one in my code because of error.
But again, PAWNO is a very mysterious world.
Re: Get distance between 2 points. -
AbyssMorgan - 05.03.2016
distance in integer, wtf
PHP код:
stock Float:GetDistanceBetweenPoints3D(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2){
return VectorSize(x1-x2,y1-y2,z1-z2);
}