2

I want to reproduce the hyperboloid of two sheet $− x^2/a^2 + y^2/b^2 − z^2/c^2 = 1$ in grayscale.

Please help. enter image description here

Below I have used the following parametrization:

x = a * sinh(θ) * cos(ϕ), y = b * sinh(θ) * sin(ϕ), z = ±c * cosh(θ)

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document} \begin{tikzpicture} \begin{axis}[ xlabel=$x$, ylabel=$y$, zlabel=$z$, domain=0:360, y domain=0:360, samples=30, view={60}{30}, ] \addplot3[surf, shader=interp, variable=\u, variable y=\v] ({sinh(\u) * cos(\v)}, {sinh(\u) * sin(\v)}, {cosh(\u)}); \addplot3[surf, shader=interp, variable=\u, variable y=\v] ({sinh(\u) * cos(\v)}, {sinh(\u) * sin(\v)}, -{cosh(\u)}); \end{axis} \end{tikzpicture} \end{document}

I have used colormap={bw}{gray(0cm)=(0); gray(1cm)=(1)} to get the fig in grayscale but it was not as prominent as the given fig. Also need to draw the traces.

Edited based on John Kormylo's suggestion:

\documentclass[tikz, margin=40]{standalone}
\usetikzlibrary{patterns}
\usepackage{tikz}

\begin{document} \begin{tikzpicture}[scale=2] \pgfmathsetmacro{\e}{1.09} % eccentricity \pgfmathsetmacro{\a}{3} \pgfmathsetmacro{\b}{(\asqrt((\e)^2-1)} \draw plot[domain=-2:2] ({\acosh(\x)},{\bsinh(\x)}); \draw plot[domain=-2:2] ({-\acosh(\x)},{\bsinh(\x)}); \draw (11.34,0) ellipse (1.2cm and 4.7cm); \draw (-11.34,0) ellipse (1.2cm and 4.7cm); \draw[fill=gray] (7.34,0) ellipse (1.2cm and 2.85cm); \draw [color=black, line width = 0.6pt] (-5, -5) -- (5, 5) node [right] {$x$}; \draw [color=black, line width = 0.6pt] (-14, 0) -- (14, 0) node [right] {$y$}; \draw [color=black, line width = 0.6pt] (0, -5) -- (0, 5) node [right] {$z$}; \draw plot[variable=\t,samples=1000,domain=-72.85:76.1] ({3sec(\t)},{.2tan(\t)}); \draw [color=black, line width = 0.6pt] (10.115, -.66) -- (12.54, .835); \draw plot[domain=-1.89:2.1086] ({-3cosh(\x)},{.2sinh(\x)}); plot[variable=\t,samples=1000,domain=-72.85:76.1] ({3sec(\t)},{.2*tan(\t)}); \draw [color=black, line width = 0.6pt] (-10.32, -.65) -- (-12.72, .825); \end{tikzpicture} \end{document}

math131
  • 149
  • 1
    Apparently, sinh and cosh use radians instead of degrees. It makes sense, since cosh(x)=exp(x)+exp(-x). – John Kormylo Oct 19 '23 at 14:10
  • The labels use normal font sizes and the axes are up to 56 cm long (with scale=2). You really need all the parallel lines to be parallel. You might also replace the ellipse on the left with two elliptical arcs (one dashed). See section 62 (page 730) of the TikZ manual for predefined patterns, and a couple of pages later on how to create new patterns. – John Kormylo Oct 20 '23 at 13:59

2 Answers2

1

This just modifies the domains used. The shading interpolater seems to arbitrarily choose which side is nearest, so I drew them one side at a time.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document} \begin{tikzpicture} \begin{axis}[ xlabel=$x$, ylabel=$y$, zlabel=$z$, domain=0:2, samples=30, view={60}{20}, ] \addplot3[surf, shader=interp, variable=\u, variable y=\v, y domain=90:270] ({sinh(\u) * cos(\v)}, {sinh(\u) * sin(\v)}, {cosh(\u)}); \addplot3[surf, shader=interp, variable=\u, variable y=\v, y domain=-90:90] ({sinh(\u) * cos(\v)}, {sinh(\u) * sin(\v)}, {cosh(\u)}); \addplot3[surf, shader=interp, variable=\u, variable y=\v, y domain=90:270] ({sinh(\u) * cos(\v)}, {sinh(\u) * sin(\v)}, {-cosh(\u)}); \addplot3[surf, shader=interp, variable=\u, variable y=\v, y domain=-90:90] ({sinh(\u) * cos(\v)}, {sinh(\u) * sin(\v)}, {-cosh(\u)}); \end{axis} \end{tikzpicture} \end{document}

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thanks a lot. Can I modify the code to get the a fig same as I have posted above? Also, I need to show the traces, as shown in the Fig. above. – math131 Oct 19 '23 at 17:47
  • The reference figure is both easier and harder than yours, nor does it use orthogonal coordinates. All it does is draw four hyperbolas and three ellipses, some filled with patterns (hatching). – John Kormylo Oct 19 '23 at 19:10
  • Thank you very much. I followed your instruction. I have edited my code and given above. I am unable to give patterns and the axis labels are very small, and needed to be increased. Please help. – math131 Oct 20 '23 at 06:31
1

This is a starting for an Asymptote alternative.

enter image description here

// http://asymptote.ualberta.ca/
import graph3;
size(200,0);
currentprojection=orthographic(3,2,1,zoom=.9);
/////////////////////////////////////
// PART 2: the 2-surface hyperboloid
// x^2/a^2 + y^2/b^2 - z^2/c^2 = - 1
real a=1, b=1, c=1;
triple g(real u,real v) {
real x=a*sinh(v)*cos(u);
real y=b*sinh(v)*sin(u);
real z=c*cosh(v);
return (x,y,z);}
// more flexibe usage: g(u,v) for g((u,v))
triple g(pair P) {return g(P.x,P.y);}

// when v = constant typedef triple gvertical(real); gvertical gv(real u) { return new triple(real v) { return g(u,v); };} // when u = constant typedef triple ghorizontal(real); ghorizontal gh(real v) { return new triple(real u) { return g(u,v); };}

surface g2hyp=surface(g,(0,0),(2pi,2),12,8,Spline); pen spen=yellow+opacity(.5); draw(g2hyp,spen,meshpen=gray+.05pt); transform3 t=zscale3(-1); draw(t*g2hyp,spen,meshpen=gray+.05pt);

dot(O,red); xaxis3("$x$",Arrow3); yaxis3("$y$",Arrow3); zaxis3("$z$",zmin=-4,zmax=6,Arrow3);

path3 ggv=graph(gv(u=1),-2,2,Spline); draw(ggv^^t*ggv,red+1.5pt); path3 ggv=ggv--cycle; // important! need to be cyclic surface s1=surface(ggv); draw(s1,red+opacity(.3));

path3 ggh=graph(gh(v=1.6),0,2pi,Spline); path3 ggh=ggh..cycle; // important! need to be cyclic draw(ggh^^t*ggh,blue+1.5pt); surface s2=surface(ggh); draw(s2,blue+opacity(.3));

//surface s=surface(ggh); //import patterns; //add("hatch",hatch()); //draw(s,blue+pattern("hatch"));

//filldraw(project(ggh), pattern("hatch"));

Black Mild
  • 17,569