How to calculate length of path data without diagonals?

Поиск
Список
Период
Сортировка
Искать

How to calculate length of path data without diagonals?

От:
Romain Billoir <billoirr@gmail.com>
Дата:
Hi, i need to calculate some length of path without diagonal. Some examples:
length((5,5),(6,6))) returns 1.41. I need 2: 5,5 to 5,6 + 5,6 to 6,6.

Is that possible?

Re: How to calculate length of path data without diagonals?

От:
John R Pierce <pierce@hogranch.com>
Дата:
On 12/23/10 10:25 AM, Romain Billoir wrote:
> Hi, i need to calculate some length of path without diagonal. Some 
> examples:
> length((5,5),(6,6))) returns 1.41. I need 2: 5,5 to 5,6 + 5,6 to 6,6.
>
> Is that possible?

a path of just two points?   something like   abs(x1-x2) + abs(y1-y2).

Re: How to calculate length of path data without diagonals?

От:
Stephen Cook <sclists@gmail.com>
Дата:
On 12/23/2010 1:25 PM, Romain Billoir wrote:
 > Hi, i need to calculate some length of path without diagonal. Some 
examples:
 > length((5,5),(6,6))) returns 1.41. I need 2: 5,5 to 5,6 + 5,6 to 6,6.
 >
 > Is that possible?


You could write a function to get the Manhattan distance between two 
points, it is the sum of the absolute values of subtracting each part of 
the coordinate. e.g. ABS(x2 - x1) + ABS(y2 - y1)


-- Stephen

Re: How to calculate length of path data without diagonals?

От:
Jasen Betts <jasen@xnet.co.nz>
Дата:
On 2010-12-23, Romain Billoir  wrote:
> --0015175ccf48e6186a049817fc59
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi, i need to calculate some length of path without diagonal. Some examples:
> length((5,5),(6,6))) returns 1.41. I need 2: 5,5 to 5,6 + 5,6 to 6,6.
>
> Is that possible?

It's called "Manhattan distance" look it up, the arithmentic is easy.

-- 
⚂⚃ 100% natural
FAQ