开发者

develop distance matrix using coordinates

开发者 https://www.devze.com 2023-01-07 20:14 出处:网络
hey, I have been given a problem, I basically have been given a piece of grid paper of arbitary size and have to develop a distance matrix using only the coordinates for each of the grid points on the

hey, I have been given a problem, I basically have been given a piece of grid paper of arbitary size and have to develop a distance matrix using only the coordinates for each of the grid points on the page.

I'm thinking the best approach would be something like the Floyd-Warshall or Djikstra algorithm开发者_StackOverflow社区s for shortest path pair, but don't know how to adapt it to coordinate distances, as all the documentation uses a pre-determined distance matrix. so any help would be grand


the distance matrix contains simply the distances to all other points.

Basically, you just have to calculate the distances using an appropriate metric. If you want the "normal" distance, it's sqrt((x1-x2)^2+(y1-y2)^2) where (x/y) are the coordinates of a point in mm / inches. If you want the distance on the paper just following the lines its |x1-x2|+|y1-y2|. Graph algorithms would be a overkill unless you have walls on the paper.

0

精彩评论

暂无评论...
验证码 换一张
取 消