Calculate distance between two x/y coordinates?

前端 未结 4 1136
面向向阳花
面向向阳花 2021-02-05 05:18

I would like to calculate the distance between two x/y coordinates on the surface of a torus. So, this is a normal grid that has the property that its corners and sides are \'co

4条回答
  •  情书的邮戳
    2021-02-05 06:11

    for points (x1,y1) and (x2,y2), you need to calculate 4 distances:

    • from (x1,y1) to (x2,y2)
    • from (x1,y1) to (x2, 500-y2)
    • from (x1,y1) to (500-x2, y2)
    • from (x1,y1) to (500-x2, 500-y2)

    and then take the minimum of those.

提交回复
热议问题