What is the shortest distance between two 2D points on the surface of a cylinder?

7.1k Views Asked by At

I'm running into an unforeseen implementation issue in my research project.

Basically, I am given two 2D points [P1 = (x1,y1) and P2 = (x2,y2)] on a sheet of paper (i.e. a 2D plane).

Next, I fold this sheet of paper into a cylinder. For example, if the leftmost x-coordinate on the x-axis is 0 and the rightmost is 999 then, after folding the paper into a cylinder, 0 and 999 are right next to each other on the x-axis (on the back/hidden side of the cylinder). In other words, the paper has been folded such that the left and right edges of the paper now touch each other.

Now, I need to find the shortest distance between P1 and P2, which are now located on the surface of this cylinder (I believe this is called a geodesic).

Unfortunately, despite hours of searching, I can't find an answer that:

a) Refers to this exact same situation.

b) Is mathematically simple enough for me to understand and implement in a program.

One answer that I found (http://www.ifsc.usp.br/~gabriel.luchini/comment_1.pdf) described this exact situation, but the equation was mind-numbingly complex, involving differentiation, integration and a ton of esoteric symbols whose meaning escapes me.

Another answer (https://stackoverflow.com/questions/7981815/projection-of-a-plane-onto-a-cylinder) seems to describe how to convert the 2D point's coordinates to equivalent 3D coordinates on the cylinder surface but I'm not sure if it's correct and, even if it was, I still wouldn't know how to calculate the distance between the resulting points.

Technically, I do know the length of 1 'arc' along the 'front' of the cylinder's surface, between the 2 points -- I assume that it is simply the same as the Euclidean distance between the same 2 points on the initial 2D plane (before I folded it into a cylinder). However, I have no idea how to get the other arc, along the 'back' of the cylinder's surface.

So, keeping in mind that my math skills are bad, would someone please give me a simple formula (without differentiation and/or integration) to find the shortest distance between two 2D points along the surface of a cylinder??

Sorry for the long question, and thanks for your time!

4

There are 4 best solutions below

1
On BEST ANSWER

As you said, a cylinder is a folded plane, so the shortest distance is given by the Pytagoras theorem. But once you folded you plane, you need to take care of the fact that it might be shorter to go through the back of the cylinder.

To know which path is shorter, you have to look at the difference in the x coordinate. If the difference between $x_1$ and $x_2$ is smaller than half of the width of your plane, then you'll take the regular distance between the point. The distance on the plane is the shortest on the cylinder. $$D(P_1, P_2) = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$$

If the difference between $x_1$ and $x_2$ is greater than half of the width of your plan, the shortest distance will go through the back of the cylinder. The difference between the $x$ will be: $\text{Width of the plan} - (x_2 - x_1)$ $$D(P_1, P_2) = \sqrt{(999-(x_2-x_1))^2 + (y_2-y_1)^2}$$

Visualize this on earth. If you want to fly from San Francisco (USA) to Tokyo (Japan). On a regular map, cut through the Pacific Ocean, you'll have to fly over the Greenwich meridian, thus going all the way accros the earth. BUt if you make a map where the cut is made in the Atlantic Ocean, then you'll see the real shortest part, across the Pacific Ocean.

3
On

Slit and unroll the cylinder. Then draw a straight line. It's a piece of a helix.

0
On

Suppose the strip of paper has width $M$, and $P_1 = (x_1,y_1)$, $P_2 = (x_2,y_2)$ are the two points. To simplify things, I'll assume that $x_1 < x_2$.

The first distance you are looking for is the straight line distance before the strip is rolled into the cylinder and is $d_1(P_1,P_2) = \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}$.

We can find the second distance (the one that wraps 'behind' the cylinder), by gluing a second copy of the strip to the leftmost edge. The copy of $P_2$ has coordinates $P_2^\prime = (x_2 - M,y_2)$, and so the distance $d(P_1,P_2^\prime) = \sqrt{(x_1 - x_2 + M)^2 + (y_1 - y_2)^2}$.

Other paths (say, with more wraps around the cylinder), can be found by gluing more copies to the edges.

0
On

If the width of your piece of paper is $w$ the distance on the cylinder will be $$\sqrt{(\Delta y)^2 + (\min\left\{w-|\Delta x|,|\Delta x|\right\})^2}$$