Does this come anywhere close to what you would want to achieve?
What I did was removing the tikz-3dplot
package, because it will give you an orthographic projection of 3D space. The first image you provided is not drawn in an orthographic projection, so it is impossible to replicate with tikz-3dplot
. (See also this and this question for why that is, explained expertly by @marmot in the latter.)
Next I set the x
, y
, and z
base vectors manually (I used \yangle
to define the y
base vector, and use that macro a few times in drawing the cylinder.).
Finally I only changed your cylinder drawing code, as function of \yangle
.
MWE:
\documentclass[border=10pt]{standalone}
\usepackage[x11names,dvipsnames,svgnames]{xcolor}
\definecolor{rusia}{RGB}{85 85 57}
\definecolor{brightcerulean}{rgb}{0.11, 0.67, 0.84}
\definecolor{brandeisblue}{rgb}{0.0, 0.44, 1.0}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{3d}
% fix wrong implementation of xy canvas
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
\def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
\def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
\def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
\tikz@canvas@is@plane
}
\makeatother
\begin{document}
\pgfmathsetmacro\yangle{30}
\begin{tikzpicture}[
y={({0.5*cos(\yangle)*1cm},{0.5*sin(\yangle)*1cm})},
x={(1cm,0cm)},
z={(0cm,1cm)}
]
\coordinate (A) at (0,0,0);
\coordinate (B) at (0,4,0);
\coordinate (C) at (5,4,0);
\coordinate (D) at (0,0,2.5);
\coordinate (E) at (0,4,1.3);
\coordinate (F) at (5,4,1.75);
\draw[very thin,canvas is xy plane at z=0,darkgray!40] (0,0) grid (5,4);
\draw[ultra thin,gray] (D)--(A)--(B)--(C)--(F);
\begin{scope}[decoration={zigzag,segment length = 1.74cm, amplitude =1mm}]
\shade (A)--(D) decorate {-- (E)}--(B)--cycle ;
\shade (B)--(E) decorate {-- (F)}--(C)--cycle ;
\end{scope}
\shade[top color=white,bottom color=brandeisblue,shading angle=45] (0.2,1,0.2) ++({0.2*cos(\yangle+90)},0,{0.2*sin(\yangle+90)}) -- ++(0,1,0) arc (\yangle+90:\yangle-90:0.2cm) -- ++(0,-1,0) arc (\yangle-90:\yangle+90:0.2cm);
\shade[ball color=Cerulean!50, shading angle=225] (0.2,1,0.2) circle (0.2cm);
\path[decoration = {zigzag,segment length = 1.74cm, amplitude =1mm},decorate] (D)--(E);
\path[decoration = {zigzag,segment length = 1.74cm, amplitude =1mm},decorate] (E)--(F);
\draw[very thin,brandeisblue!70] (0.2,1,0.2) circle (0.2cm) ++({0.2*cos(\yangle+90)},0,{0.2*sin(\yangle+90)}) -- ++(0,1,0) arc (\yangle+90:\yangle-90:0.2cm) -- ++(0,-1,0);
\end{tikzpicture}
\end{document}
@Max: please feel free to revert the changes that follow:
\documentclass[border=10pt]{standalone}
\usepackage[x11names,dvipsnames,svgnames]{xcolor}
\definecolor{rusia}{RGB}{85 85 57}
\definecolor{brightcerulean}{rgb}{0.11, 0.67, 0.84}
\definecolor{brandeisblue}{rgb}{0.0, 0.44, 1.0}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{3d}
% fix wrong implementation of xy canvas
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
\def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
\def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
\def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
\tikz@canvas@is@plane
}
\makeatother
\begin{document}
\pgfmathsetmacro\yangle{30}
\begin{tikzpicture}[
y={({0.5*cos(\yangle)*1cm},{0.5*sin(\yangle)*1cm})},
x={(1cm,0cm)},
z={(0cm,1cm)}
]
\coordinate (A) at (0,0,0);
\coordinate (B) at (0,4,0);
\coordinate (C) at (5,4,0);
\coordinate (D) at (0,0,2.5);
\coordinate (E) at (0,4,1.3);
\coordinate (F) at (5,4,1.75);
\draw[very thin,canvas is xy plane at z=0,darkgray!40] (0,0) grid (5,4);
\draw[ultra thin,gray] (D)--(A)--(B)--(C)--(F);
\begin{scope}[decoration={zigzag,segment length = 1.74cm, amplitude =1mm}]
\shade (A)--(D) decorate {-- (E)}--(B)--cycle ;
\shade (B)--(E) decorate {-- (F)}--(C)--cycle ;
\end{scope}
\draw[thick,opacity=0.3] (0.2,1.5,0) -- ++ (0.5,0,0) coordinate (rod end);
\shade[top color=white,bottom color=brandeisblue,shading angle=45] (0.2,1,0.2) ++({0.2*cos(\yangle+90)},0,{0.2*sin(\yangle+90)}) -- ++(0,1,0) arc (\yangle+90:\yangle-90:0.2cm) -- ++(0,-1,0) arc (\yangle-90:\yangle+90:0.2cm);
\shade[ball color=Cerulean!50, shading angle=225] (0.2,1,0.2) circle (0.2cm);
\path[decoration = {zigzag,segment length = 1.74cm, amplitude =1mm},decorate] (D)--(E);
\path[decoration = {zigzag,segment length = 1.74cm, amplitude =1mm},decorate] (E)--(F);
\draw[very thin,brandeisblue!70] (0.2,1,0.2) circle (0.2cm) ++({0.2*cos(\yangle+90)},0,{0.2*sin(\yangle+90)}) -- ++(0,1,0) arc (\yangle+90:\yangle-90:0.2cm) -- ++(0,-1,0);
\begin{scope}
\clip (0.2,1,0.2) ++({0.2*cos(\yangle+90)},0,{0.2*sin(\yangle+90)}) -- ++(0,1,0) arc (\yangle+90:\yangle-90:0.2cm) -- ++(0,-1,0) arc (\yangle-90:\yangle+90:0.2cm);
\draw[thick,opacity=0.3,line cap=round] (0.2,1.5,0.2) ++({0.2*cos(\yangle+90)},0,{0.2*sin(\yangle+90)}) arc (\yangle+90:\yangle-90:0.2cm);
\end{scope}
\path (0.2,1,0.2) ++({-0.2*cos(\yangle+90)},0.5,{0.2*sin(\yangle+90)}) --
(rod end) coordinate[pos=-1] (rod start);
\draw[thick] (rod start) -- (rod end);
\end{tikzpicture}
\end{document}