# Is it possible to change position of the segment so that it is parallel to Y axis?

Let's consider infinite Cartesian system of coordinates. Assume that in any lattice point (i.e. both coordinates are integers) there is a spike. I have a line segment of length $n$ (it is an integer). It is parallel to X axis, as shown below (image shows only a part of system of coordinates).

I want to make it parallel to Y axis as shown below.

What I can do is rotate and move this line segment, but without raising it up. I can't change shape, length etc. of it. Movement and rotation, as you can see, is limited by the spikes in lattice points. Below is an example of one of possible moves. My question: is it possible to make this line segment parallel to Y-axis?

I do believe that Chinese Remainder Theorem has something to do with this.

• It can be done if and only if the length of line segment is less than $\sqrt{2}$ – user160738 Feb 24 '17 at 16:51
• Why is that true? – user4201961 Feb 24 '17 at 16:52
• If the length is less than $\sqrt{2}$ it can be put inside a single square, and from there putting one vertex "close" to a lattice point and rotating the the line about that point you can move the line segment to vertical position. This can be done because diagonal of square has length $\sqrt{2}$. If the length is at least $\sqrt{2}$, just considering one vertex of the line, wherever it is positioned in a single square, you cannot escape that square via rotating because the other end will always be out of the squre, as length is at least the diagonal. – user160738 Feb 24 '17 at 16:56
• This is not a mathematical argument, but I don't know why you can't slide the segment to the left so the right end is just shy of a lattice point. Now rotate it counterclockwise so the end is above the lattice point. Slide the segment to the right and increase the angle. Now, instead of the segment being contained between two integers $a$ and $a+1$, now it's between $a$ and $a+2$. If the length of the segment is 2, you are done. If the length is longer, repeat until the segment is vertical. – scott Feb 24 '17 at 17:16
• @scott I don't think that will work without changing length of the segment. After you've rotated, when you slide right, how do you know the other end part of segment doesn't cross the lattice point? I think it should. – user160738 Feb 24 '17 at 18:49

Put an edge of the stick in the point $O=(\sqrt 2,1/2)$. Consider all points with integer coordinates which have distance from $0$ not larger than $n+1$ ($n$ is the length of the stick). These are a finite number of points. Order them by their angle with respect to $O$: $\alpha_1, \dots, \alpha_N$. Since $O$ has an irrational coordinate, all points have a different angle (not really important) and moreover if there is a point with angle $\alpha$ there is no point with angle $\alpha+\pi$ (this is used to simplify the algorithm). To make the stick rotate around the point $O$ it is enough to describe a "move" to pass across each pin. Let $\alpha$ be the angle of the pin $P$. Since the circle of radius $n+1$ centered in $O$ contains a finite number of pins, there is a small angle around $\alpha$ and around $\alpha+\pi$ which contains no pins apart from $P$. Also a small circle around $O$ contains no pins (not really needed). The pin can then move in the orange region of the picture. You can easily translate it in the opposite sector, rotate a little and translate back to pass the point $P$.

A very similar problem: http://mathworld.wolfram.com/KakeyaNeedleProblem.html

• Any chance you could illustrate your algorithm with an example? The procedure is not clear to me. – Jens Mar 5 '17 at 3:08
• It is not easy to explain. However I found a simpler algorithm which is maybe more clear. Look again at the answer (and the picture). – Emanuele Paolini Mar 5 '17 at 8:23
• When you say "$-\alpha$", do you mean $\alpha+\pi$? And when you say "... translate it in the opposite sector, rotate a little..." do you mean that you rotate the left end of the stick down, using the point $O$ as axis? If so, I don't see how you know the left end of the stick doesn't cross any spikes. – Jens Mar 9 '17 at 15:02
• @Jens: right: I mean the opposite direction which is $\alpha + \pi$. There are no pins there because the line has irrational slope, so it cannot contain two points with integer coordinates. – Emanuele Paolini Mar 9 '17 at 19:27
• very clever approach indeed!! – G Cab Mar 9 '17 at 23:21

If both the "spikes" and the "segment" are infinitesimally thin, and the plane is infinite, then I do believe it is always possible to rotate the segment to any angle.

I don't have the math-fu to prove this mathematically, but I can describe a simple iterative algorithm that should achieve this rotation:

1. Move the line segment furthest away from any lattice point (maximizing the minimum distance to a lattice point).

2. Rotate the line segment (in the same direction), until it reaches the desired orientation, or touches a lattice point.

3. If the line segment touches only one lattice point, repeat at step 1.

4. Move the line along its length so that the lattice point stopping the desired rotation is just past the end of the line segment, allowing the line segment to be rotated (in the same direction) again.

5. Repeat at step 2.

If there is an interesting enough underlying problem here, it would not be that difficult to create a numerical simulator or GUI/minigame for this -- say, using Python and Qt for readability and portability.

I just realized that in the case of infinitely thin spikes and infinitely thin line segment of any length, all possible states can be divided in two categories: "pinned" and "free". The phase space of such a system is continuous (as opposed to discrete), but not completely connected.

(You can think of the phase space of a line segment of some specific length L as an unit cube, possibly repeated inifinitely, depending on how you define the coordinates. The x and y coordinates correspond to the position of the center of the line segment, and the z coordinate corresponds to the orientation, say line segment making angle $z·180°$ with the $x$ axis, measured counterclockwise.)

"Pinned" states are those where no rotation is possible, and movement is restricted to the direction along the line segment. "Free" states are those where rotation is possible at least in one direction; because the line segment is infinitesimally thin, movement is also always possible in the "free" states.

"Free" and "pinned" states may only be connected via states without rotation. If the line segment is long enough to be pinned (in that orientation) by at least four pins, the "pinned" state is disconnected from the "free" states, because movement is only possible along the direction of the line segment, and the line segment stays pinned by at least three pins at all times due to symmetry in the simple cubic lattice.

To prove that a line segment of some length can be rotated to any angle, one needs to prove that the phase space for a line segment of that length has a connected region that includes both the initial and the final orientations.

Based on the existence of algorithms like mine above and the variant gue implemented in their answer, the phase space for the "free" states of a specific length line segment is connected. This connected region contains all orientations of the line segment.

What I do not know, is whether the above is sufficient proof.

The interesting thing, and the reason this question is so tricky to think of, is that for a line segment of sufficient length, the phase space is fragmented: there is one connected "free" region, dotted with small only internally connected "pinned" regions. (Again, I'm not sure I've proven this, but this is my current understanding.)

Thus, the only "risk" in an algorithm that rotates such a line segment is that one of its moves causes the line segment to be "pinned", leading to a deadlock.

• I agree that the problem of "pinning" appears to be an issue. I ran into this when trying manually with $n=10$. – Jens Mar 5 '17 at 2:57

This is no formal proof. Step by step construction works just fine for $n=4.5$ and $7$. For an arbitrary $n$ I would also support @Nominal Animal's answer, that it is always possible if the spikes and line segment are infinitely small, thin. Images are for $n=4.5$ (the $.5$ happened by accident), for $n=7$ look at the PDF (this is in IPE format, so one can manually recheck).

I guess an argument in the formal proof would be that even for an arbitrary large $n$. If we position the segment $\ell$ in the center of a square such that the endpoints are horizontally aligned with the grid points, then we can rotate $\ell$ past the two grid-points (left/right) where the endpoints of $\ell$ reside.

• A minor comment to your examples: the lengths appear to be $n=4.5$ and $n=7$. – Jens Mar 5 '17 at 2:53
• Hey, yes you are right, my mistake. – gue Mar 5 '17 at 22:22