3

I'm trying for the fun to reproduce the following figure in TikZ:

Three common types of curvatures

So far i have been able to get:

but the result i get looks quite bad in my opinion and the way i have started to build the triangles seems not soo god (and i failed for the sphere):

enter image description here

The LaTeX code is here:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{tikz,tikz-3dplot}
\usepackage{xcolor}
\usetikzlibrary{calc,3d,intersections, positioning,intersections,shapes}
\begin{document}

%hyperboloid
\begin{tikzpicture}
    %triangle definition
    \tikzset{declare function={%
        fx(\x)=ifthenelse(\x<0,0.75*(\x+1),0.75*(-\x+1));
        fy(\y)=ifthenelse(\y<0,0,ifthenelse(\y>1,-2+\y,-\y));
    }}
    \begin{axis}[hide axis,view={-20}{45},scale=0.8]
    \addplot3 [surf,draw=black,domain=-1.2:1.2,domain y=-1.5:1.5,opacity=0.5] {x^2-y^2};
    \addplot3 [domain=-2:2,samples=81,smooth,fill=green,fill opacity=0.1] ({fx(x)},{fy(x)},{fx(x)^2-fy(x)^2});
    \end{axis}
\end{tikzpicture}
%sphere
\begin{tikzpicture}
    \begin{axis}[hide axis,axis equal,width=8cm,height=8cm,domain=-1:1,domain y=-1:1 ]
    \addplot3[%
        opacity = 0.5,
        surf,draw=black,
        z buffer = sort,
        variable = \u,
        variable y = \v,
        domain = 0:180,
        y domain = 0:360,
    ]
    ({cos(u)*sin(v)}, {sin(u)*sin(v)}, {cos(v)});
    \end{axis}
    \newcommand{\InterSec}[3]{%
    \path[name intersections={of=#1 and #2, by=#3, sort by=#1,total=\t}]
    \pgfextra{\xdef\InterNb{\t}}; }
    \pgfmathsetmacro\R{2} 
    
    \foreach \angle[count=\n from 1] in {-5,225,290} {

      \begin{scope}[rotate=\angle,transform canvas={xshift = 3.2cm,yshift=3.4cm}]
        \path[draw,dashed,name path global=d\n] (2,0) arc [start angle=0,
         end angle=180,
         x radius=2cm,
       y radius=1cm] ;
       \path[draw,name path global=s\n] (-2,0) arc [start angle=180,
          end angle=360,
          x radius=2cm,
        y radius=1cm] ;
     \end{scope}
   }
   \begin{scope}[transform canvas={xshift = 3.2cm,yshift=3.4cm}]
   \InterSec{s1}{s2}{I3} ;
    \InterSec{s1}{s3}{I2} ;
    \InterSec{s3}{s2}{I1} ;
    %
    \fill[fill=green,opacity=0.5] (I1) to [bend right=8.5]  (I2) to [bend left=7] 
    (I3) to [bend left=6] (I1);
    \end{scope}
\end{tikzpicture}
%plane
\begin{tikzpicture}
    \begin{axis}[hide axis,
    xlabel=$x$, ylabel=$y$, zlabel = $z$,,scale=0.8
    ]
    \addplot3[
    surf,draw=black, shader=flat,
    domain=-5:5,
    domain y=-5:5,
    samples =10,
    opacity = 0.5
    ] {x + 2*y -1};
    
    \draw[black, very thick,fill=green,fill opacity=0.1] (-2, -3, -8) -- (2, 2, 5) -- (-1, 4, 7) -- cycle;
    
    \end{axis}
\end{tikzpicture}

\end{document} 

Thanks for your help!

2
  • Well, I think you already got the basic code. Now, it is rather a matter of chosing the right colors etc. What exactly don't you like with the current output? Commented Mar 2, 2023 at 12:01
  • What i don't like: i failed to put the triangle on the sphere. I don't know how to put the perpendicular lines. To get just that result representing ~30% of the final result i spent almost 15 hours of my time when very likely an expert in Tikz/Pgfplot would spend 1 hour to do the whole result. Commented Mar 2, 2023 at 13:24

0

You must log in to answer this question.

Browse other questions tagged .