6

What I am trying to draw is a half cone with the peak at the middle of a braun bar right behind the wind turbine, which got cut by the vertical plane. The intersection line is marked red.

This is what I have achieved with the codes following the picture.

a 3D cone cut by a vertical plane

Here are the codes:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}


\begin{document}

\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[scale=1,tdplot_main_coords]%,fill opacity=0.5]
\def\ALength{2}
\def\AWidth{0.3}
\def\Dist{5}
\def\ratio{1.8}
\def\ShiftDist{2.5}

\begin{scope}[canvas is yz plane at x=-\Dist]
    % draw rotor plane
    \fill [ blue!10,fill opacity=0.5, shift={(\ShiftDist,0)}] 
        (-\ShiftDist,0) rectangle (\ShiftDist,\Dist*\ratio,0);

    % draw wind turbine with help of https://tex.stackexchange.com/questions/173560/wind-power-and-tikz-force
    \tikzset{path/.style={fill, draw=white, 
        ultra thick, line join=round}}
    \foreach \i in {60, 180, 300}{
        \path [path, shift={(\ShiftDist,3)}, rotate=\i] 
            (0,0.125) -- (2,0.125) -- (2,0) -- (0.5,-0.375) -- cycle;
    }
    \path [path, shift={(\ShiftDist,0)}] (-.25,0) arc (180:360:.25 and .0625) 
        -- (.0625,3) -- (-.0625,3) -- cycle;
    \path [path, shift={(\ShiftDist,0)}] 
        (0,3) (-0.25,-0.25+3) rectangle (0.25,0.25+3);  
\end{scope}

\coordinate (Ovir) at (0,0,0);

\draw[thick,dashed,->] (Ovir)--(1,0,0) node{$x$};
\draw[thick,dashed,->] (Ovir)--(0,1,0) node{$y$};
\draw[thick,dashed,->] (Ovir)--(0,0,1) node{$z$};   

\draw[dashed,color=black!50] (-\Dist*\ratio,0,0)--(\Dist*\ratio,0,0);
\foreach \a in {0,15,...,180} {
    \draw[thin,color=black!50]
        (0,\ShiftDist,0)--({cos(\a)*\Dist*\ratio},0,{sin(\a)*\Dist*\ratio});
}

% draw the circle edge of cone
\tdplotsetrotatedcoords{90}{90}{90}
\tdplotdrawarc[tdplot_rotated_coords,color=black!50]
    {(0,0,0)}{\Dist*\ratio}{0}{180}{}{};    

\coordinate (Shift) at (0,\ShiftDist,0);
\tdplotsetrotatedcoords{90}{0}{0}
\tdplotsetrotatedcoordsorigin{(Shift)}

% draw the braun bar behind the turbine
\draw[thick,tdplot_rotated_coords,color=yellow!50!black,fill]%
    (-\ALength/2,\AWidth/2,0)--(-\ALength/2,-\AWidth/2,0)--
    (\ALength/2,-\AWidth/2,0)--(\ALength/2,\AWidth/2,0)--
    (-\ALength/2,\AWidth/2,0)--cycle;

\coordinate[tdplot_rotated_coords] (O) at (0,0,0);

\draw[dashed,tdplot_rotated_coords,color=black!50] (O)--(0,\Dist,0);

\draw[thick,tdplot_rotated_coords,->] (O)--(1,0,0) node[anchor=north]{$x$};
\draw[thick,tdplot_rotated_coords,->] (O)--(0,1,0) node[anchor=south west]{$y$};
\draw[thick,tdplot_rotated_coords,->] (O)--(0,0,1) node[anchor=south]{$z$};     

\begin{scope}[canvas is yz plane at x=-\Dist]
    \draw[domain=0:(\ShiftDist*(\ratio-1)/\ratio),smooth,variable=\t,red] 
        plot({\t},{sqrt( \Dist*\Dist*\ratio*\ratio*(\ShiftDist-\t)*(\ShiftDist-\t)/\ShiftDist/\ShiftDist-\Dist*\Dist )});   
\end{scope}

My questions are:

  1. Here I drew several straight lines to represent the surface of the cone. But I think ideally is to draw the cone surface using \tdplotsphericalsurfaceplot. However I failed because the z-axis seems to be the only rotation axis when using \tdplotsphericalsurfaceplot and I cannot rotate the coordinate system so that z-axis points horizontally. Can someone please show me how?

  2. The red line is supposed to be the interaction of the cone surface and the vertical plane. I drew it using mathematical formulas. Is there any more convenient and automatic way of drawing it?

  3. The whole picture does not look very 3D because the cone surface behind the cutting plane should be dashed, or at least not covering the turbine blade and the plane like now in the picture. Do I have to plot the straight lines seperately? That means, in front of the plane normal and behind it dashed? Any better way to draw them??

  4. Am I allowed to shift the rotated coordinate system several times? I tried it but TexMaker just crashed. This limited the order and flexibility of drawing badly.

Last but not least, any comments and suggestions are welcomed and appreciated. Any small idea can help me learn tikz.

Best regards, Shelmy

1 Answer 1

7

This answer does not address all your points. In particular, I do not address the \tdplotsphericalsurfaceplot part since I personally am not too excited about the output. As to the intersection of the cone and the plane: I do not know any real alternative to the analytic computation. However, once you have this intersection curve, you can also use it to make the pic more 3D-like. You can use \clip to draw the parts behind the plane dashed and the parts in front solid. The question on the shifts I do not understand. What have you tried specifically to cause these crash?

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}


\begin{document}

\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[scale=1,tdplot_main_coords]%,fill opacity=0.5]
\def\ALength{2}
\def\AWidth{0.3}
\def\Dist{5}
\def\ratio{1.8}
\def\ShiftDist{2.5}

\begin{scope}
\clip[overlay]  plot[domain=0:(\ShiftDist*(\ratio-1)/\ratio),smooth,variable=\t] (-\Dist,{\t},{sqrt( \Dist*\Dist*\ratio*\ratio*(\ShiftDist-\t)*(\ShiftDist-\t)/\ShiftDist/\ShiftDist-\Dist*\Dist )})
        -- (-\Dist,{(\ShiftDist*(\ratio-1)/\ratio)},-1)
        -- (-\Dist-5,{(\ShiftDist*(\ratio-1)/\ratio)},-1)
        -- (-\Dist-5,{(\ShiftDist*(\ratio-1)/\ratio)},2*\Dist) -- cycle;   
\foreach \a in {0,15,...,180} {
    \draw[thin,color=black!50,dashed]
        (0,\ShiftDist,0)--({cos(\a)*\Dist*\ratio},0,{sin(\a)*\Dist*\ratio});
}

% draw the circle edge of cone
\tdplotsetrotatedcoords{90}{90}{90}
\tdplotdrawarc[tdplot_rotated_coords,color=black!50,dashed]
    {(0,0,0)}{\Dist*\ratio}{0}{180}{}{};    

\end{scope}

\begin{scope}[canvas is yz plane at x=-\Dist]
    % draw rotor plane
    \fill [ blue!10,fill opacity=0.5, shift={(\ShiftDist,0)}] 
        (-\ShiftDist,0) rectangle (\ShiftDist,\Dist*\ratio,0);

    % draw wind turbine with help of https://tex.stackexchange.com/questions/173560/wind-power-and-tikz-force
    \tikzset{path/.style={fill, draw=white, 
        ultra thick, line join=round}}
    \foreach \i in {60, 180, 300}{
        \path [path, shift={(\ShiftDist,3)}, rotate=\i] 
            (0,0.125) -- (2,0.125) -- (2,0) -- (0.5,-0.375) -- cycle;
    }
    \path [path, shift={(\ShiftDist,0)}] (-.25,0) arc (180:360:.25 and .0625) 
        -- (.0625,3) -- (-.0625,3) -- cycle;
    \path [path, shift={(\ShiftDist,0)}] 
        (0,3) (-0.25,-0.25+3) rectangle (0.25,0.25+3);  
\end{scope}

\coordinate (Ovir) at (0,0,0);

\draw[thick,dashed,->] (Ovir)--(1,0,0) node{$x$};
\draw[thick,dashed,->] (Ovir)--(0,1,0) node{$y$};
\draw[thick,dashed,->] (Ovir)--(0,0,1) node{$z$};   

\draw[dashed,color=black!50] (-\Dist*\ratio,0,0)--(\Dist*\ratio,0,0);
\begin{scope}
\clip[overlay] (-\Dist,{0},{sqrt(
\Dist*\Dist*\ratio*\ratio*(\ShiftDist)*(\ShiftDist)/\ShiftDist/\ShiftDist-\Dist*\Dist+25)})
-- plot[domain=0:(\ShiftDist*(\ratio-1)/\ratio),smooth,variable=\t] 
(-\Dist,{\t},{sqrt( \Dist*\Dist*\ratio*\ratio*(\ShiftDist-\t)*(\ShiftDist-\t)/\ShiftDist/\ShiftDist-\Dist*\Dist )})
        -- (-\Dist,{(\ShiftDist*(\ratio-1)/\ratio)},-3)
        -- (-\Dist+20,{(\ShiftDist*(\ratio-1)/\ratio)},-3)
        -- (-\Dist+20,{(\ShiftDist*(\ratio-1)/\ratio)},2.5*\Dist) -- cycle;
\foreach \a in {0,15,...,180} {
    \draw[thin,color=black!50]
        (0,\ShiftDist,0)--({cos(\a)*\Dist*\ratio},0,{sin(\a)*\Dist*\ratio});
}

% draw the circle edge of cone
\tdplotsetrotatedcoords{90}{90}{90}
\tdplotdrawarc[tdplot_rotated_coords,color=black!50]
    {(0,0,0)}{\Dist*\ratio}{0}{180}{}{};    
\end{scope}
\coordinate (Shift) at (0,\ShiftDist,0);
\tdplotsetrotatedcoords{90}{0}{0}
\tdplotsetrotatedcoordsorigin{(Shift)}

% draw the braun bar behind the turbine
\draw[thick,tdplot_rotated_coords,color=yellow!50!black,fill]%
    (-\ALength/2,\AWidth/2,0)--(-\ALength/2,-\AWidth/2,0)--
    (\ALength/2,-\AWidth/2,0)--(\ALength/2,\AWidth/2,0)--
    (-\ALength/2,\AWidth/2,0)--cycle;

\coordinate[tdplot_rotated_coords] (O) at (0,0,0);

\draw[dashed,tdplot_rotated_coords,color=black!50] (O)--(0,\Dist,0);

\draw[thick,tdplot_rotated_coords,->] (O)--(1,0,0) node[anchor=north]{$x$};
\draw[thick,tdplot_rotated_coords,->] (O)--(0,1,0) node[anchor=south west]{$y$};
\draw[thick,tdplot_rotated_coords,->] (O)--(0,0,1) node[anchor=south]{$z$};     



\begin{scope}[canvas is yz plane at x=-\Dist]
    \draw[domain=0:(\ShiftDist*(\ratio-1)/\ratio),smooth,variable=\t,red] 
        plot({\t},{sqrt( \Dist*\Dist*\ratio*\ratio*(\ShiftDist-\t)*(\ShiftDist-\t)/\ShiftDist/\ShiftDist-\Dist*\Dist )});   
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Rather than drawing the cone with \tdplotsphericalsurfaceplot, which I didn't even try, one can use pgfplots. (In principle one could draw the full pic with pgfplots but I wanted to try something new: combine them. It turns out to be rather straightforward.)

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\newsavebox\Cone
\sbox\Cone{\begin{tikzpicture}
\begin{axis}[view={-70}{20},hide axis,axis equal,scale=5,colormap/blackwhite]
 \addplot3[surf,shader=interp,point meta=-y-0.3*z,domain=0:180,domain y=0:2.5,
 mesh/ordering=x varies] 
 ({9*y*cos(x)/2.5},{y},{9*y*sin(x)/2.5});
\end{axis}
\end{tikzpicture}}
\begin{document}



\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[scale=1,tdplot_main_coords]%,fill opacity=0.5]
\def\ALength{2}
\def\AWidth{0.3}
\def\Dist{5}
\def\ratio{1.8}
\def\ShiftDist{2.5}

\begin{scope}
\clip[overlay]  plot[domain=0:(\ShiftDist*(\ratio-1)/\ratio),smooth,variable=\t] (-\Dist,{\t},{sqrt( \Dist*\Dist*\ratio*\ratio*(\ShiftDist-\t)*(\ShiftDist-\t)/\ShiftDist/\ShiftDist-\Dist*\Dist )})
        -- (-\Dist,{(\ShiftDist*(\ratio-1)/\ratio)},-1)
        -- (-\Dist-5,{(\ShiftDist*(\ratio-1)/\ratio)},-1)
        -- (-\Dist-5,{(\ShiftDist*(\ratio-1)/\ratio)},2*\Dist) -- cycle;   
\path let \p1=($({-\Dist*\ratio},0,0)-({\Dist*\ratio},0,0)$),\n1={\x1/\wd\Cone}
 in node[anchor=south west,opacity=0.3,inner sep=0pt,outer sep=0pt,scale=\n1] 
 at ({\Dist*\ratio},0,0) {\usebox\Cone};

\foreach \a in {0,15,...,180} {
    \draw[thin,color=black!50,dashed]
        (0,\ShiftDist,0)--({cos(\a)*\Dist*\ratio},0,{sin(\a)*\Dist*\ratio});
}

% draw the circle edge of cone
\tdplotsetrotatedcoords{90}{90}{90}
\tdplotdrawarc[tdplot_rotated_coords,color=black!50,dashed]
    {(0,0,0)}{\Dist*\ratio}{0}{180}{}{};    

\end{scope}

\begin{scope}[canvas is yz plane at x=-\Dist]
    % draw rotor plane
    \fill [ blue!10,fill opacity=0.5, shift={(\ShiftDist,0)}] 
        (-\ShiftDist,0) rectangle (\ShiftDist,\Dist*\ratio,0);

    % draw wind turbine with help of https://tex.stackexchange.com/questions/173560/wind-power-and-tikz-force
    \tikzset{path/.style={fill, draw=white, 
        ultra thick, line join=round}}
    \foreach \i in {60, 180, 300}{
        \path [path, shift={(\ShiftDist,3)}, rotate=\i] 
            (0,0.125) -- (2,0.125) -- (2,0) -- (0.5,-0.375) -- cycle;
    }
    \path [path, shift={(\ShiftDist,0)}] (-.25,0) arc (180:360:.25 and .0625) 
        -- (.0625,3) -- (-.0625,3) -- cycle;
    \path [path, shift={(\ShiftDist,0)}] 
        (0,3) (-0.25,-0.25+3) rectangle (0.25,0.25+3);  
\end{scope}

\coordinate (Ovir) at (0,0,0);

\draw[thick,dashed,->] (Ovir)--(1,0,0) node{$x$};
\draw[thick,dashed,->] (Ovir)--(0,1,0) node{$y$};
\draw[thick,dashed,->] (Ovir)--(0,0,1) node{$z$};   

\draw[dashed,color=black!50] (-\Dist*\ratio,0,0)--(\Dist*\ratio,0,0);
\begin{scope}
\clip[overlay] (-\Dist,{0},{sqrt(
\Dist*\Dist*\ratio*\ratio*(\ShiftDist)*(\ShiftDist)/\ShiftDist/\ShiftDist-\Dist*\Dist+25)})
-- plot[domain=0:(\ShiftDist*(\ratio-1)/\ratio),smooth,variable=\t] 
(-\Dist,{\t},{sqrt( \Dist*\Dist*\ratio*\ratio*(\ShiftDist-\t)*(\ShiftDist-\t)/\ShiftDist/\ShiftDist-\Dist*\Dist )})
        -- (-\Dist,{(\ShiftDist*(\ratio-1)/\ratio)},-3)
        -- (-\Dist+20,{(\ShiftDist*(\ratio-1)/\ratio)},-3)
        -- (-\Dist+20,{(\ShiftDist*(\ratio-1)/\ratio)},2.5*\Dist) -- cycle;
\path let \p1=($({-\Dist*\ratio},0,0)-({\Dist*\ratio},0,0)$),\n1={\x1/\wd\Cone}
 in node[anchor=south west,opacity=1,inner sep=0pt,outer sep=0pt,scale=\n1] 
 at ({\Dist*\ratio},0,0) {\usebox\Cone};


\foreach \a in {0,15,...,180} {
    \draw[thin,color=black!50]
        (0,\ShiftDist,0)--({cos(\a)*\Dist*\ratio},0,{sin(\a)*\Dist*\ratio});
}

% draw the circle edge of cone
\tdplotsetrotatedcoords{90}{90}{90}
\tdplotdrawarc[tdplot_rotated_coords,color=black!50]
    {(0,0,0)}{\Dist*\ratio}{0}{180}{}{};    
\end{scope}

\coordinate (Shift) at (0,\ShiftDist,0);
\tdplotsetrotatedcoords{90}{0}{0}
\tdplotsetrotatedcoordsorigin{(Shift)}

% draw the braun bar behind the turbine
\draw[thick,tdplot_rotated_coords,color=yellow!50!black,fill]%
    (-\ALength/2,\AWidth/2,0)--(-\ALength/2,-\AWidth/2,0)--
    (\ALength/2,-\AWidth/2,0)--(\ALength/2,\AWidth/2,0)--
    (-\ALength/2,\AWidth/2,0)--cycle;

\coordinate[tdplot_rotated_coords] (O) at (0,0,0);

\draw[dashed,tdplot_rotated_coords,color=black!50] (O)--(0,\Dist,0);

\draw[thick,tdplot_rotated_coords,->] (O)--(1,0,0) node[anchor=north]{$x$};
\draw[thick,tdplot_rotated_coords,->] (O)--(0,1,0) node[anchor=south west]{$y$};
\draw[thick,tdplot_rotated_coords,->] (O)--(0,0,1) node[anchor=south]{$z$};     



\begin{scope}[canvas is yz plane at x=-\Dist]
    \draw[domain=0:(\ShiftDist*(\ratio-1)/\ratio),smooth,variable=\t,red] 
        plot({\t},{sqrt( \Dist*\Dist*\ratio*\ratio*(\ShiftDist-\t)*(\ShiftDist-\t)/\ShiftDist/\ShiftDist-\Dist*\Dist )});   
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

2
  • With pure pgfplots it would be even easier because there one can add restrict y to domain....
    – user121799
    Jun 16, 2019 at 1:55
  • Many thanks for your great help, marmot! And I have downloaded a pgfplots manual for learning :)
    – Shelmy
    Jun 16, 2019 at 20:33

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.