You will need to use a Euclidean distance formula (specifically for 2 dimensions). Basically the formula is:
d = sqrt((x1 - x2)^2 + (y1 - y2)^2)
d
is your final distancesqrt
is the square root (thesqrt()
function in PHP)x1
andy1
are your x-y coordinates for your first pointx2
andy2
are your x-y coordinates for your second point^2
means raise to the second power (use thepow()
function for PHP)
Pythagoras was the Greek philosopher who developed the Pythagorean Theorem, which can be used to derive the 2-dimensional distance formula (which is different from Euclid's derivation).