math - Calculate distance between two x/y coordinates? -
I would like to calculate the distance between two x / y coordinates on the surface of. Therefore, this is a common grid whose asset is, whose corners and sides are 'connected'. For example, on a 500x500 grid, (49 9, 499) is connected to the point (0, 0) and the distance between the example (0,0) and (0, 495) then is 5.
Is there a good mathematical way to calculate this?
So you are looking for Euclidean distance on the two-dimensional surface of Torus, I am gathered.
sqrt (minus (| x1 - x2 |, w - | x1 - x2 |) ^ 2 + min (| y1 - y2 |, h - | y1 - y2.) ^ 2)
Where w
and h
are grid width (x) and height (Y) respectively.
Comments
Post a Comment