06.11.2010, 16:58

is there a function to calculate the distance between points?

if there's not can someone create one please?

if there's not can someone create one please?

pointtopoint()

06.11.2010, 16:58

is there a function to calculate the distance between points?

if there's not can someone create one please?

if there's not can someone create one please?

06.11.2010, 17:04

There are loads of them, i prefer using a fast plugin-based.

But this one should do its job too

(untested)

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

}

06.11.2010, 17:56

isnt that pythagoras?

06.11.2010, 18:35

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.

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.

06.11.2010, 19:09

so its 3 dimensional pythagoras?

kewl xd

kewl xd

Users browsing this thread: 1 Guest(s)