get distance between two points.
#1

Hi,

How to get distance between two coordinates?
Ex:

Код:
945.544,489.54,45.164

2015.554,1103.10.98
Reply
#2

try that, didnt test but it should work. calculating distances is a big deal. Only do if you really have to and there's no other way 'round it.

Код:
stock Float:GetDistance(Float:x1,Float:y1,Float:z1, Float:x2,Float:y2,Float:z2)
{
	return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
you could use it like

Код:
new s[13];
format(s, sizeof s,"Distance: %f",GetDistance(945.544,489.54,45.164,2015.554,1103.10.98,45.2));
SendClientMessage(playerid,-1,s);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)