I want to plot an optical fiber as in the picture below:
As you can see, the drawing is composed of three concentric cylinders of different radii. This question is about drawing just one of those, say the right, small radius one.
My code up until now is this:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{3d}
\begin{tikzpicture}
%Opaque frame so it is easier to get the 3d visualization.
\begin{scope}[opacity=0.3]
\draw(-0.25,1,1) -- (0.25,1,1);
\draw(-0.25,1,1) -- (-0.25,1,-1);
\draw(-0.25,1,1) -- (-0.25,-1,1);
\draw(0.25,1,1) -- (0.25,1,-1);
\draw(0.25,1,1) -- (0.25,-1,1);
\draw(0.25,1,-1) -- (-0.25,1,-1);
\draw(0.25,1,-1) -- (0.25,-1,-1);
\draw(-0.25,1,-1) -- (-0.25,-1,-1);
\draw(-0.25,-1,1) -- (0.25,-1,1);
\draw(0.25,-1,-1) -- (0.25,-1,1);
\draw(0.25,-1,-1) -- (-0.25,-1,-1);
\draw(-0.25,-1,-1) -- (-0.25,-1,1);
\end{scope}
% Draw the cylinder planes
\begin{scope}[canvas is zy plane at x=0.25]
\draw (0,0) circle (1);
\end{scope}
\begin{scope}[canvas is zy plane at x=-0.25]
\draw (0,0) circle (1);
\end{scope}
% Draw the edges, this is the tricky part.
\draw (-0.25,1,0) -- (0.25,1,0);
\end{tikzpicture}
\end{document}
output:
As you can see this last command that makes a straight line from the upper visible part from right to left is not actually where it should be. Any one have an idea on how to parametrically derive the "correct 3d" coordinates for this kind of lines?
Alternatively, I tried working with shapes.geometric and its cylinder primitive:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{3d}
\usetikzlibrary {shapes.geometric}
\begin{tikzpicture}
\begin{scope}[opacity=0.3]
\draw(-0.25,1,1) -- (0.25,1,1);
\draw(-0.25,1,1) -- (-0.25,1,-1);
\draw(-0.25,1,1) -- (-0.25,-1,1);
\draw(0.25,1,1) -- (0.25,1,-1);
\draw(0.25,1,1) -- (0.25,-1,1);
\draw(0.25,1,-1) -- (-0.25,1,-1);
\draw(0.25,1,-1) -- (0.25,-1,-1);
\draw(-0.25,1,-1) -- (-0.25,-1,-1);
\draw(-0.25,-1,1) -- (0.25,-1,1);
\draw(0.25,-1,-1) -- (0.25,-1,1);
\draw(0.25,-1,-1) -- (-0.25,-1,-1);
\draw(-0.25,-1,-1) -- (-0.25,-1,1);
\end{scope}
\node[cylinder,draw,minimum height=0.5cm,minimum width=1] (c) {};
\end{tikzpicture}
\end{document}
output:
Well not bad, but I have two questions about its specification:
- How to set its front and ens planes?
- How to set its radius to be equal to 2 so to fill up this rectangular prism's height and width? How to specify its depth to be equal to 0.5, as the prism's depth?




\newcommands. I am afraid there is no detour, and I need to carefully read this solution and write it down in my drawing in a cleaner way. – tush May 03 '21 at 18:08