0

Suppose an ant is walking on the boundary of the square $[0,1]\times[0,1]$. I have trouble finding a formula for the shortest path from $(x_1,y_1)$ to $(x_2,y_2)$ on the square. Is there a straightforward solution? What if the ant is walking on the boundary of the cube $[0,1]\times[0,1]\times[0,1]$?

Update: I have an idea. I should define a function for the distance from the origin. Well it's obviously $x+y$, but the distance between two points is not necessarily the difference of the distances from the origin. However, if we define the clockwise distance from the origin, then subtraction of the distances from the origin would mean something, although it doesn't always work.

asmani
  • 241
  • What formulas do you have? Can you consider cases based on which sides have the points? – Michael Burr Nov 15 '22 at 16:14
  • Yes, there are three cases; on the same side, opposite sides or adjacent sides. – asmani Nov 15 '22 at 16:24
  • 1
    Assuming only the rim is usable, consider the boundary as a straight line. There will be 2 paths to use to get to the destination (left or right). Get the min (left path, right path). – NoChance Nov 16 '22 at 06:40

0 Answers0