Coordinates system (PHP an array)
-
28-09-2019 - |
Question
I have point A(x,y) and B(x,y). they listed as array (a => array(x,y), b => array(x,y))
How get lenght between point A and B. Please help in php. :)
Solution
Well, remember your high-school geometry.
r = square_root((x2 - x1)^2 + (y2 - y1)^2)
So in php:
$dx = $points['b'][0] - $points['a'][0];
$dy = $points['b'][1] - $points['a'][1];
$r = sqrt(pow($dx, 2) + pow($dy, 2));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow