SA-MP Forums Archive
Distance between two points - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Distance between two points (/showthread.php?tid=74952)



Distance between two points - NtCat - 27.04.2009

Hi. I need to know which is the distance between these two points:
-2545.3506,-474.8006
595.0517,2698.5789
That are X and Y coordinates from GTA:SA, I just need the distance thanks for help


Re: Distance between two points - yom - 27.04.2009

pawn Код:
stock Float:Distance2D(Float:x1, Float:y1, Float:x2, Float:y2, bool:sqrt = true)
{
  x1 -= x2;
  x1 *= x1;

  y1 -= y2;
  y1 *= y1;

  x1 += y1;

  return sqrt ? floatsqroot(x1) : x1;
}
pawn Код:
new Float:distance = Distance2D(-2545.3506, -474.8006, 595.0517, 2698.5789);



Re: Distance between two points - Weirdosport - 27.04.2009

Using the above script I made it to be: 4464.578613