# Drawing continuous modular line in tikz

I have a one dimensional vector space V=span{(1,\sqrt 2)} and I want to draw its image mod 1 under a matrix A. Is there a way to draw continuously (unlike this question here) the line beginning in (0,0), passing through (1,\sqrt(2)-1) and so on?

Roughly speaking that should look like this (modulu my slopy hands):

• \clip(0,0)rectangle(1,1); and then draw slope-√2 lines that passes integral coordinates. Sep 23 at 4:19
• @Symbol1 what do you mean by "passes integral coordinates"? the red line does not intersect the sides of the square only in integer points. Can you please draw a MWE? Sep 23 at 4:26
• Given that the full picture would be indistinguishable to the eye from a filled square, how many times round the modular process would you like to go? Sep 23 at 5:52

\documentclass[border=9,tikz]{standalone}

\begin{document}

\tikz{
\clip(0,0)rectangle(10,10);
\foreach\x in{0,...,10}{
\foreach\y in{0,...,20}{
\draw(-\x0,-\y0)--+(100,141.421);
}
}
}

\end{document}


A proof that this works

\tikz{
\clip(0,0)rectangle(10,10);
\foreach\x in{0,...,3}{
\foreach\y in{0,...,10}{
\draw(-\x0,-\y0)--+(100,141.421);
}
}
\foreach\x in{1,...,5}{
\draw[blue,dotted]({mod(7.07106*\x,10)},0)--+(0,10);
}
\foreach\x in{1,...,3}{
\draw[red,dotted](0,{mod(4.14213*\x,10)})--+(10,0);
}
}


An animation that shows how line grow

\foreach\frame in{0,...,40}{
\tikz{
\clip(0,0)rectangle(10,10);
\foreach\x in{-5,...,5}{
\foreach\y in{-8,...,8}{
\fill[shift={(\x0,\y0)},scale=\frame/10]
(-.2,.2)--(10,14.1421)--
(.2,-.2)--(-10,-14.1421)--cycle;
}
}
}
}


Bonus

• -+(100,41.421) could be better... Sep 23 at 5:02
• Doesn't that change the slope to √2-1? I mean, I am not sure if OP wants √2 or √2-1 though. Sep 23 at 5:08
• Exact: the first sentence is unclear ! :-) Sep 23 at 5:10
• I think the sqrt(2)-1 is the result of applying the matrix A to the original line. Sep 23 at 5:51
• I said that my brain wasn't working! Now that it is, I agree that this is the right approach. Sep 23 at 7:22