# How to graph a hyperboloid of a leaf with intersections using tikzpicture environment

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:

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}


Please note the imperfection from z<=0:

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. Nov 9 '18 at 5:53

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
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)});
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);
% vertical plane: lower part
\fill[cyan,opacity=0.4] (1,5,0) -- (1,-5,0) -- (1,-5,-5)
-- (1,5,-5);
% lower front part
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);
% upper back part
domain=-4:4]        ({x},{sqrt(1+x*x)},{0});
domain=-4:4]        ({x},{-sqrt(1+x*x)},{0});
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);
domain=0:180] ({1},{sqrt(1+1)*cos(x)},{sqrt(1+1)*sin(x)});
% upper front part
domain=1:4] ({x},{sqrt(1+x*x)*cos(y)},{sqrt(1+x*x)*sin(y)});
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}


• I see some shadowing effects in the extremum locations in the OP's example which I miss here (But still a +1 from me). Nov 9 '18 at 6:20
• 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. Nov 9 '18 at 6:22
• @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.
– user121799
Nov 9 '18 at 6:30
• @marmot Super!! Nov 9 '18 at 6:58
• @marmot Super.....man!!! +1 :-) Nov 9 '18 at 17:03