3

I have trouble plotting these 3D graphs of Quadric surfaces. If anybody could help or direct me to a link where I can find codes for corresponding graphs, it would be really helpful.

Hyperbolic paraboloid enter image description here

Elliptical Cone enter image description here

enter image description here

1 Answer 1

6

Something like this?

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.16,trig format plots=rad,xtick=\empty,ytick=\empty,ztick=\empty}
\begin{document}
\begin{tikzpicture}
 \matrix{
 \begin{axis}[axis lines=middle]
  \addplot3[domain=-5:5,domain y=-5:5,surf,z
  buffer=sort,shader=interp,opacity=0.5] 
  (x*x-y*y,x,y);
 \end{axis}\\
 \begin{axis}[axis lines=middle]
  \addplot3[domain=-3:3,domain y=0:2*pi,surf,z
  buffer=sort,shader=interp,opacity=0.5] 
  (x,{x*cos(y)},{x*sin(y)});
 \end{axis}\\
 \begin{axis}[axis lines=middle]
  \addplot3[domain=-3:-1,domain y=0:2*pi,surf,z
  buffer=sort,shader=interp,opacity=0.5] 
  (x,{sqrt(x*x-1)*cos(y)},{sqrt(x*x-1)*sin(y)});
  \addplot3[domain=1:3,domain y=0:2*pi,surf,z
  buffer=sort,shader=interp,opacity=0.5] 
  (x,{sqrt(x*x-1)*cos(y)},{sqrt(x*x-1)*sin(y)});
 \end{axis}\\
 };
\end{tikzpicture}
\end{document}

enter image description here

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.16,}
\begin{document}
\begin{tikzpicture}[pics/x axis/.style={code={\draw 
    (\pgfkeysvalueof{/pgfplots/xmin},0,0) -- 
        (\pgfkeysvalueof{/pgfplots/xmax},0,0);}},
    pics/y axis/.style={code={\draw 
    (0,\pgfkeysvalueof{/pgfplots/ymin},0) -- 
        (0,\pgfkeysvalueof{/pgfplots/ymax},0);}},
  /pgfplots/.cd,trig format plots=rad,hide axis,colormap/viridis]
 \matrix{
 \begin{axis}
  \addplot3[domain=-5:5,domain y=-5:0,surf,z
   buffer=sort,shader=interp]   (x*x-y*y,x,y);
  \path pic{x axis} pic{y axis};
  \addplot3[domain=-5:5,domain y=0:5,surf,z
   buffer=sort,shader=interp]   (x*x-y*y,x,y);
  \draw (0,0,0) -- (0,0,25); 
 \end{axis}\\
 \begin{axis}
  \addplot3[domain=-3:3,domain y=pi:2*pi,surf,z
   buffer=sort,shader=interp] 
   (x,{x*cos(y)},{x*sign(x)*sin(y)});
  \path pic{x axis} pic{y axis};
  \addplot3[domain=-3:3,domain y=0:pi,surf,z
   buffer=sort,shader=interp] 
   (x,{x*cos(y)},{x*sign(x)*sin(y)});
  \draw (0,0,0) -- (0,0,3);  
 \end{axis}\\
 \begin{axis}
  \addplot3[domain=-3:-1,domain y=pi:2*pi,surf,z
    buffer=sort,shader=interp] 
    (x,{sqrt(x*x-1)*cos(y)},{sqrt(x*x-1)*sin(y)});
  \addplot3[domain=1:3,domain y=pi:2*pi,surf,z
    buffer=sort,shader=interp] 
   (x,{sqrt(x*x-1)*cos(y)},{sqrt(x*x-1)*sin(y)});
  \path pic{x axis} pic{y axis};
  \addplot3[domain=-3:-1,domain y=0:pi,surf,z
    buffer=sort,shader=interp] 
    (x,{sqrt(x*x-1)*cos(y)},{sqrt(x*x-1)*sin(y)});
  \addplot3[domain=1:3,domain y=0:pi,surf,z
    buffer=sort,shader=interp] 
   (x,{sqrt(x*x-1)*cos(y)},{sqrt(x*x-1)*sin(y)});
  \draw (0,0,0) -- (0,0,{sqrt(8)}); 
 \end{axis}\\
 };
\end{tikzpicture}
\end{document}

enter image description here

3
  • Could you tell me what needs to be done if I need to rotate the cone?. For ex: If I need to make the cone symmetric about Z-axis (instead of X-axis), what needs to be added to the existing code?
    – SL_MathGuy
    Commented Jan 19, 2020 at 18:10
  • 1
    @SL_MathGuy I am not really online now and plan to add an example later. One way to achieve this is to swap the first and last components of the vectors after \addplot3 ...
    – user194703
    Commented Jan 19, 2020 at 18:20
  • @ Schrödinger's cat Thanks.That worked!!
    – SL_MathGuy
    Commented Jan 19, 2020 at 18:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .