2

How to draw curved cone in 3D with a given curvature or radius? Here is coding for straight cone.

\tdplotsetmaincoords{70}{0}
\begin{tikzpicture}[tdplot_main_coords]
\def\RI{2}
\def\RII{1.25}

\draw[thick] (\RI,0)
  \foreach \x in {0,300,240,180} { --  (\x:\RI) node at (\x:\RI) (R1-\x) {} };
\draw[dashed,thick] (R1-0.center)
  \foreach \x in {60,120,180} { --  (\x:\RI) node at (\x:\RI) (R1-\x) {} };
\path[fill=gray!30] (\RI,0)
  \foreach \x in {0,60,120,180,240,300} { --  (\x:\RI)};

\begin{scope}[yshift=3.5cm]
\draw[thick,fill=gray!20,opacity=0.5] (\RII,0)
  \foreach \x in {0,60,120,180,240,300,360}
    { --  (\x:\RII) node at (\x:\RII) (R2-\x) {}};
\end{scope}

\foreach \x in {0,180,240,300} { \draw (R1-\x.center)--(R2-\x.center); };
\foreach \x in {60,120} { \draw[dashed] (R1-\x.center)--(R2-\x.center); };
\end{tikzpicture}
  • @M.AlJumaily I'm sorry for accidentally rejecting your edit suggest. – user156344 May 16 at 7:40
  • Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a \documentclass command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code. – Andrew May 16 at 8:28
  • What precisely do you mean by "curved cone"? Curvature is a tensor, so which edges should curved? BTW, this produces an almost identical picture and contains a complete code that starts with \documentclass and ends with \end{document}. – user121799 May 16 at 12:24
5

Your code produces a truncated hexagonal cube, and I added some curvature.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot} 
\begin{document}
\tdplotsetmaincoords{20}{00}
\begin{tikzpicture}[tdplot_main_coords,declare
function={r1=2;r2=1.25;h=3;curvature=1;}]
 \path[fill=gray!50] plot[variable=\x,samples at={0,60,...,300}] 
    ({r1*cos(\x)},0,{r1*sin(\x)});
 \draw[thick,dashed] plot[variable=\x,samples at={0,60,120,180}] 
    ({r1*cos(\x)},0,{r1*sin(\x)});
 \draw[thick] plot[variable=\x,samples at={180,240,300,0}] 
    ({r1*cos(\x)},0,{r1*sin(\x)});
 \foreach \X in {60,120,...,360}
 {\draw[thick] \ifnum\X<180 [dashed] \fi 
 plot[variable=\x,domain=r2:r1]
 ({(\x+curvature*(\x-r1)*(\x-r2))*cos(\X)},{-h*(\x-r1)/(r1-r2)},{(\x+curvature*(\x-r1)*(\x-r2))*sin(\X)});}
 \path[fill=gray!25,fill opacity=0.8] plot[variable=\x,samples at={0,60,...,300}] 
 ({r2*cos(\x)},h,{r2*sin(\x)});
 \draw[thick,dashed,gray!40] plot[variable=\x,samples at={0,60,120,180}] 
 ({r2*cos(\x)},h,{r2*sin(\x)});
 \draw[thick,gray!40] plot[variable=\x,samples at={180,240,300,0}]
 ({r2*cos(\x)},h,{r2*sin(\x)});
\end{tikzpicture}
\end{document}

enter image description here

The mandatory animation.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot} 
\begin{document}
\tdplotsetmaincoords{20}{00}
\foreach \CC in {5,15,...,355}
{\pgfmathsetmacro{\curvature}{sin(\CC)}
\begin{tikzpicture}[tdplot_main_coords,declare
function={r1=2;r2=1.25;h=3;curvature=\curvature;}]
\path[tdplot_screen_coords,use as bounding box] (-1.1*r1,{-1.2*sin(\tdplotmaintheta)*r1})
 rectangle (1.1*r1,{h+1.2*sin(\tdplotmaintheta)*r2});
 \path[fill=gray!50] plot[variable=\x,samples at={0,60,...,300}] 
    ({r1*cos(\x)},0,{r1*sin(\x)});
 \draw[thick,dashed] plot[variable=\x,samples at={0,60,120,180}] 
    ({r1*cos(\x)},0,{r1*sin(\x)});
 \draw[thick] plot[variable=\x,samples at={180,240,300,0}] 
    ({r1*cos(\x)},0,{r1*sin(\x)});
 \foreach \X in {60,120,...,360}
 {\draw[thick] \ifnum\X<180 [dashed] \fi 
 plot[variable=\x,domain=r2:r1]
 ({(\x+curvature*(\x-r1)*(\x-r2))*cos(\X)},{-h*(\x-r1)/(r1-r2)},{(\x+curvature*(\x-r1)*(\x-r2))*sin(\X)});}
 \path[fill=gray!25,fill opacity=0.8] plot[variable=\x,samples at={0,60,...,300}] 
 ({r2*cos(\x)},h,{r2*sin(\x)});
 \draw[thick,dashed,gray!40] plot[variable=\x,samples at={0,60,120,180}] 
 ({r2*cos(\x)},h,{r2*sin(\x)});
 \draw[thick,gray!40] plot[variable=\x,samples at={180,240,300,0}]
 ({r2*cos(\x)},h,{r2*sin(\x)});
\end{tikzpicture}}
\end{document}

enter image description here

ADDENDUM Everything bent in the same direction, which is given by bd in the following code.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot} 
\begin{document}
\tdplotsetmaincoords{20}{00}
\begin{tikzpicture}[tdplot_main_coords,declare
function={r1=2;r2=1.25;h=3;curvature=1;bd=0;}]
 \path[fill=gray!50] plot[variable=\x,samples at={0,60,...,300}] 
    ({r1*cos(\x)},0,{r1*sin(\x)});
 \draw[thick,dashed] plot[variable=\x,samples at={0,60,120,180}] 
    ({r1*cos(\x)},0,{r1*sin(\x)});
 \draw[thick] plot[variable=\x,samples at={180,240,300,0}] 
    ({r1*cos(\x)},0,{r1*sin(\x)});
 \foreach \X in {60,120,...,360}
 {\draw[thick] \ifnum\X<180 [dashed] \fi 
 plot[variable=\x,domain=r2:r1]
 ({\x*cos(\X)-curvature*(\x-r1)*(\x-r2)*cos(bd)},{-h*(\x-r1)/(r1-r2)},
    {\x*sin(\X)-curvature*(\x-r1)*(\x-r2)*sin(bd)});}
 \path[fill=gray!25,fill opacity=0.8] plot[variable=\x,samples at={0,60,...,300}] 
 ({r2*cos(\x)},h,{r2*sin(\x)});
 \draw[thick,dashed,gray!40] plot[variable=\x,samples at={0,60,120,180}] 
 ({r2*cos(\x)},h,{r2*sin(\x)});
 \draw[thick,gray!40] plot[variable=\x,samples at={180,240,300,0}]
 ({r2*cos(\x)},h,{r2*sin(\x)});
\end{tikzpicture}
\end{document}

enter image description here

  • Thank you so much. So great ! How to draw each edge is bent the same side ? – ntt May 17 at 3:24
  • @nft What do you mean by this? This is a 3d picture. Do you want to bend every bent edge in the same direction? – user121799 May 17 at 3:54
  • Yes. It looks like an arc (a half circle) with the first and end sections are hexagonal sections. – ntt May 17 at 4:15
  • @ntt I added something of that sort. – user121799 May 17 at 4:27
  • Thank you so much for your kind reply. I really appreciate your help. – ntt May 17 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.