Get distance between 2 points.
#1

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
Reply
#2

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 ) ) ) ) );
}
Reply
#3

thanks, gona give it a try, will post back here with results
Reply
#4

It works for what I needed, thanks a lot.
Reply
#5

This is in meters? or Kilometers?
Reply
#6

I failed. wrong post.
Reply
#7

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 ')'
Reply
#8

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"
Reply
#9

IDK but I had to remove one in my code because of error.
But again, PAWNO is a very mysterious world.
Reply
#10

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);

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)