add tag
Anonymous 1123
I am trying to draw an oblique cylinder, some thing like this

![ScreenHunter 232.png](/image?hash=6e48c76e4acc7a5f6c37262b342902b25671dafb07f1ff7ce3498d288d2120be)

or

![ScreenHunter 234.png](/image?hash=590d205c4a47f8894cdaacb75be58a3f2d72abf12c85930de399a8a1ab71910b)

I tried
```
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{3dtools,calc}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
	\begin{tikzpicture}[3d/install view={phi=200,theta=70},
		line cap=butt,line join=round,c/.style={circle,fill,inner sep=1pt},
		declare function={r=3;h=4;}] 
\pgfmathsetmacro{\sdtip}{screendepth(0,0,h)}
\pgfmathsetmacro{\aspectangle}{atan2(\sdtip,sqrt(h*h-\sdtip*\sdtip))}
\path (0,0,h) coordinate (-tip);
\pgfmathsetmacro{\myex}{TDunit("(0,0,1)x(nscreenx,nscreeny,nscreenz)")}%
\pgfmathsetmacro{\myey}{TDunit("(0,0,1)x(nscreenx,nscreeny,nscreenz)")}%
\pgfmathsetmacro{\sdtip}{screendepth(0,0,h)}
\path (0,0,{tan(\aspectangle)}) coordinate (-tmpex) 
(\myey) coordinate (-tmpey);	
\begin{scope}[x={(-tmpex)},y={(-tmpey)}]
\pgfmathsetmacro{\alphacrit}{acos(tan(\aspectangle)*r/h)}
\path[3d/hidden] (\alphacrit:r) arc[start angle=\alphacrit,end
angle=-\alphacrit,radius=r];
\path[3d/visible] (\alphacrit:r) 
arc[start angle=\alphacrit,end  angle=360-\alphacrit,radius=r]
;
\path
({r*cos(\alphacrit)},{r*sin(\alphacrit)},0) coordinate (A)
({r*cos(-\alphacrit)},{-r*sin(\alphacrit)},0) coordinate (B)
(0,0,h) coordinate (S)
[3d coordinate ={(T) = (A) - (B) + (-tip) }, 3d coordinate ={(O') = 0.5*(-tip)  + 0.5*(T)}];
\draw (O') circle[radius = r]  (B) -- (-tip) -- (T) -- (A);
\end{scope}
	%\path foreach \p/\g in {A/90,B/0,S/0,T/0}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
	
	\end{tikzpicture}	
\end{document}

```
I got

![ScreenHunter 233.png](/image?hash=8231a0f3c9e7949a974176534b132ecca56f69af55bef26e13b5f83c1756512e)


How to draw an oblique cylinder?
Top Answer
marmot
This is a code that draws such an oblique cylinder. However, at this point the result is not fully rotatable.
```
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{3dtools,calc}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=00,theta=70},
	line cap=butt,line join=round,c/.style={circle,fill,inner sep=1pt},
	declare function={R=1.5;dx=1;h=3;}] 
  \path (0,0,0) coordinate (O) (dx,0,h) coordinate (O');
  \pgfmathsetmacro{\myex}{TDunit("(0,0,1)x(nscreenx,nscreeny,nscreenz)")}%
  \pgfmathsetmacro{\myey}{TDunit("(0,0,1)x(\myex)")}%
  \path (0,0,1) coordinate (ez) (\myey) coordinate (ey) (\myex) coordinate (ex);
  \pgfmathsetmacro{\sdtip}{screendepth(0,0,h)}
  \pgfmathsetmacro{\aspectangle}{atan2(\sdtip,sqrt(h*h-\sdtip*\sdtip))}
  \begin{scope}[x={(ex)},y={(ey)},z={(ez)}]
   \pgfmathsetmacro{\alphacrit}{acos(tan(\aspectangle)*R/h)-90}
   \draw[3d/hidden] (\alphacrit:R)
   	arc[start angle=\alphacrit,end angle=180+\alphacrit,radius=R];
   \draw 
    % the following two lines are for the shading, if you comment them
	% you will not get shading
    let \p1=($(O')-(O)$),\n1={atan2(\y1,\x1)} in
    [left color=red,right color=red,middle color=white,shading angle=\n1]
   (\alphacrit:R) -- ($(O')+(\alphacrit:R)$) 
   	arc[start angle=\alphacrit,end angle=-180+\alphacrit,radius=R] 
	-- (-180+\alphacrit:R)
	arc[start angle=-180+\alphacrit,end angle=\alphacrit,radius=R] ;
   \draw[3d/visible,fill=cyan] (O') circle[radius=R];
  \end{scope}
\end{tikzpicture}
\end{document}   
```
![Screen Shot 2021-06-11 at 9.05.57 AM.png](/image?hash=a81c0435e69ffb3d8b3d0b72f6d7ca1c1890700a0e5ab7b75d38a7ad22069afd)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.