pointtopoint()
is there a function to calculate the distance between points?

if there's not can someone create one please?
There are loads of them, i prefer using a fast plugin-based.
But this one should do its job too

pawn Код:
`stock Float:PointToPoint(Float:x, Float:y, Float:z, Float:xx, Float:yy, Float:zz){    return floatsqroot( (x - xx) * (x - xx) + (y - yy) * (y - yy) + (z - zz) * (z - zz) );}`
(untested)
isnt that pythagoras?
Quote:
 Originally Posted by legodude isnt that pythagoras?
Pythagoras:
aІ+bІ=cІ

We've got:
xІ+yІ+zІ=aІ

It has it's origin from Pythagoras, but we just added another dimension.
Proof that it works:

Imagine the world would be a coordination system. We've got a triangle, so we first use Pythagoras to get the distance of the points on the ground level:
xІ+yІ=d(xy)І

d(xy) means the distance, from X to Y.

Now, when we've got the ground level, we add the altitude, Z. We get this:

d(xy)І+zІ=d(xyz)І

Now we can easily replace d(xy)І with xІ+yІ. What we get looks like this:

xІ+yІ+zІ=d(xyz)І

We want d(xyz), not d(xyz)І, so we use the squareroot. Now we've got:

√(xІ+yІ+zІ) = √d(xyz)І = d(xyz)

I don't know if this was necessary for you, but it might help some people to understand the background of the code.
so its 3 dimensional pythagoras?

kewl xd

Forum Jump:

Users browsing this thread: 1 Guest(s)