0

Can someone help me to draw a figure of many lines through the origin

enter image description here

like the above figure but without the plan, and the dashed parts. I wish to create an effect of a line in movement.

1 Answer 1

4

Here is a way using the 3dtools library from here. Maybe one fine day when GitHub becomes more accessible to users with some math background this library will become part of CTAN... This library allows us to access the coordinates and compute the intersection with the plane analytically.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{intersections,perspective,3d,3dtools}
\begin{document}
\begin{tikzpicture}[3d view={30}{15}]
 \path (0,0,0) coordinate (O) 
  foreach \X[count=\Y] in {(3,0,0),(2,1,1),(2,0,3),(1,1,3),(0,0,3)}
   {(O) -- \X coordinate (p\Y) coordinate[pos=-0.3] (p-\Y)};
 \path[canvas is xy plane at z=2,fill=blue!30] (
 (-4,-4) coordinate (r1) -- (4,-4) coordinate
 (r2) -- (4,4)  coordinate
 (r3) -- (-4,4) -- cycle;
 \path[name path=edge] (r1) -- (r2)  -- (r3); 
 \foreach \Y in {1,...,5}
 {\path[name path=ray] (p-\Y) -- (p\Y);
 \path[name intersections={of=edge and ray,total=\t},draw,thick]
 \ifnum\t=1
  (p-\Y) -- (intersection-1) coordinate (i-\Y)
 \else 
  (p-\Y) -- (p\Y)
 \fi;
 \pgfmathsetmacro{\itest}{TD("(p\Y)o(0,0,1)")}
 \ifdim\itest pt>0pt
  \pgfmathsetmacro{\tt}{2/TD("(p\Y)o(0,0,1)")}
  \ifdim\tt pt<1pt
   \pgfmathsetmacro{\myint}{TD("\tt*(p\Y)")}
   \draw[thick,dashed] (\myint) -- (i-\Y);
   \draw[thick] (\myint) node[circle,inner sep=1pt,fill]{} -- (p\Y);
  \fi
 \fi
 }
\end{tikzpicture}
\end{document}

enter image description here

5
  • This sounds über cool! Note that if you don't want to store a generated PDF file in the repository, I've found that you can still offer it for download on GitHub by uploading it to a wiki (GitHub wiki for your project; for example, see Instructions and examples for expsagetex—that section has a link to the rendered manual in PDF format) .
    – frougon
    Mar 27, 2020 at 8:54
  • @frougon There are basically two versions of manuals. Either they assume you are a computing expert or they assume that you are super dumb and cannot even add two numbers. It would be great if there was something that does not assume you are a computing expert but also does not assume you do not know any math or logic.
    – user194703
    Mar 27, 2020 at 14:00
  • Mmm, yeah, but I'm not sure I see the connection with what I wrote. Do you mean that my link to the PDF in README.md is too difficult to discover, and that an in-repo generated PDF next to the .tex avoids the problem of users not finding the already-compiled documentation?
    – frougon
    Mar 27, 2020 at 14:08
  • @frougon Yes, you are right, I am just frustrated with GitHub.
    – user194703
    Mar 27, 2020 at 14:13
  • Right, their interface has a few problems for making documentation accessible, indeed. I struggled to find this wiki thing, and even then, it's not perfect.
    – frougon
    Mar 27, 2020 at 14:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .