I would like to plot S1: -(x-1)^2+y^2+z^2=1, x=1 and z=0 and their intersections using tikzpicture environment:

Graph

Using this post about the equation of the hyperboloid of a leaf I end up with two type of equations.

Let x^2/a^2 + y^2/b^2 - z^2/c^2 = 1.

  • Parametric equation:
    • x=a*cosh(u)*cos(v)
    • y=b*cosh(u)*sin(v)
    • z=c*sinh(u)
      • for any real u
      • for 0º <= v <= 360º
  • Non-Hyperbolic equation:
    • x=a*sqrt(1+u*u)*cos(v)
    • y=b*sqrt(1+u*u)*sin(v)
    • z=c*u
      • for any real u
      • for 0º <= v <= 360º

In our case, the first surface is a=b=c=1, but the - sign is in x-term, not z, so this is my first problem; I do not know how to change the order. Also note that S1 is moved one unit on the x-axis.

The other plots are x=1 and z=0.

Also, if possible, I would like to draw the intersections of these surfaces, i.e. there are two:

  • Intersection of S1 and y^2+z^2=1 gives the orange curve,
  • Intersection of S1 and z=0 gives the green curve.

Also I think the view is view={135}{25} but you can propose other good view!

(Very) basic MWE (I do not know why S1 is of z-axis when it should be x-axis ???):

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{center}
\begin{tikzpicture}
    \begin{axis}[
        legend pos=outer north east,
        axis lines = center,
        xticklabel style = {font=\tiny},
        yticklabel style = {font=\tiny},
        zticklabel style = {font=\tiny},
        xlabel = $x$,
        ylabel = $y$,
        zlabel = $z$,
        legend style={cells={align=left}},
        legend cell align={left},
        view={135}{25},
        clip=false
        ]
        \addplot3[surf, mesh/ordering=y varies,shader=interp,samples = 71,samples y=41,variable = \u,variable y = \v,domain =-360:360] ({(1+u*u)^(1/2)*cos(v)+1},{sqrt(1+u*u)*sin(v)},{u});
    \end{axis}
\end{tikzpicture}
\end{center}

\end{document}

Hyperboloid of a leaf

Please note the imperfection from z<=0: Imperfections

Thanks!

  • Some solutions that come to my mind: for the imperfections use domain=-360-something:360-something and for the x-axis just flip z parametric equation and x parametric equation. – manooooh Nov 9 at 5:53
up vote 7 down vote accepted

Something like this? (I think that the strange effect came from the domain -360:360. If you want to have more of a 3d feel, you need to decompose the hyperboloid anyway in pieces. This also fixes the domain problem. I also respond to Raaja, whom I'd like to thank for the nice suggestion to add some (fake) shading.

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\pgfplotsset{colormap={cm}{color(0)=(red) color(1)=(red!90)
color(3)=(red!80) color(4)=(red!70) color(5)=(red!10)}}

\begin{document}

\begin{center}
\begin{tikzpicture}
    \begin{axis}[
        legend pos=outer north east,
        axis lines = middle,
        xticklabel style = {font=\tiny},
        yticklabel style = {font=\tiny},
        zticklabel style = {font=\tiny},
        xlabel = $x$,
        ylabel = $y$,
        zlabel = $z$,
        legend style={cells={align=left}},
        legend cell align={left},
        view={135}{25},
        clip=false,
        point meta={z-abs(0.2*x+y)}
        ]
        % lower back part
        \addplot3[surf,mesh/ordering=y varies,shader=interp,opacity=0.7,
        samples=71,samples y=41,domain y=-180:00,domain=-4:1]
        ({x},{sqrt(1+x*x)*cos(y)},{sqrt(1+x*x)*sin(y)});
        \addplot3[ultra thick,color=green,samples=71,samples y=1,
        domain=-180:00] ({1},{sqrt(1+1)*cos(x)},{sqrt(1+1)*sin(x)});
        % horizontal plane: back
        \fill[cyan,opacity=0.4] (1,5,0) -- (1,-5,0) -- (-4.5,-5,0) 
        -- (-4.5,5,0);
        %\addplot3[surf,cyan,domain=-4.5:1,domain y=-5:5,opacity=0.5] {0};
        % vertical plane: lower part
        \fill[cyan,opacity=0.4] (1,5,0) -- (1,-5,0) -- (1,-5,-5) 
        -- (1,5,-5);
        %\addplot3[surf,cyan,domain=-4.5:0,domain y=-5:5,opacity=0.5] ({1},{y},{x});
        % lower front part
        \addplot3[surf,mesh/ordering=y varies,
        shader=interp,opacity=0.7,samples=71,samples y=41,domain y=-180:00,
        domain=1:4] ({x},{sqrt(1+x*x)*cos(y)},{sqrt(1+x*x)*sin(y)});
        % horizontal plane: front
        \fill[cyan,opacity=0.4] (1,5,0) -- (1,-5,0) -- (5,-5,0) 
        -- (5,5,0);
        %\addplot3[surf,cyan,domain=1:4.5,domain y=-5:5,opacity=0.5] {0};
        % upper back part
        \addplot3[ultra thick,color=orange,samples=71,samples y=1,
        domain=-4:4]        ({x},{sqrt(1+x*x)},{0});
        \addplot3[ultra thick,color=orange,samples=71,samples y=1,
        domain=-4:4]        ({x},{-sqrt(1+x*x)},{0});
        \addplot3[surf,mesh/ordering=y varies,
        shader=interp,opacity=0.7,samples=71,samples y=41,domain y=0:180,
        domain=-4:1]
        ({x},{sqrt(1+x*x)*cos(y)},{sqrt(1+x*x)*sin(y)});
        % vertical plane: upper part
        \fill[cyan,opacity=0.4] (1,5,0) -- (1,-5,0) -- (1,-5,5) 
        -- (1,5,5);
        \addplot3[ultra thick,color=green,samples=71,samples y=1,
        domain=0:180] ({1},{sqrt(1+1)*cos(x)},{sqrt(1+1)*sin(x)});
        %\addplot3[surf,cyan,domain=0:4.5,domain y=-5:5,opacity=0.5] ({1},{y},{x});
        % upper front part
        \addplot3[surf,mesh/ordering=y varies,
        shader=interp,opacity=0.7,samples=71,samples y=41,domain y=0:180,
        domain=1:4] ({x},{sqrt(1+x*x)*cos(y)},{sqrt(1+x*x)*sin(y)});
    \end{axis}
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

  • 1
    I see some shadowing effects in the extremum locations in the OP's example which I miss here (But still a +1 from me). – Raaja Nov 9 at 6:20
  • 1
    That's an excellent good start. Did you "delete" the y varies effect to show better the graph? Also, I would like to graph the two intesections for then add a legend to every plot. – manooooh Nov 9 at 6:22
  • 1
    @Raaja Thanks! I added one possibility to add some shading. Clearly, there are more sophisticated options. This is just my first guess for an appropriate point meta. – marmot Nov 9 at 6:30
  • 1
    @marmot Super!! – Raaja Nov 9 at 6:58
  • 1
    @marmot Super.....man!!! +1 :-) – Sebastiano Nov 9 at 17:03

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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