Water inside a hemispherical bowl

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
6
down vote

favorite












I am trying to draw the diagram below in latex
What I want



I got this far with the following code:
progress



documentclassarticle
usepackage[margin=0.5in]geometry
usepackagepgfplots
renewcommandthesectionarabicsection
usepackagemathtools
usepackagecancel
usepackagepgfplots
usepackageamsmath
newtheoremtheoremTHEOREM
newtheoremproofPROOF
usepackagetikz
usepackageamssymb
usetikzlibrarypatterns
usepackagefancyhdr
usepackagebigints
usepackagecolor
usepackagetcolorbox
usepackagecolor,xcolor
usepackagebooktabs,array
usepackagehyperref
usepackagegraphicx
usetikzlibraryarrows
usepackagepolynom
usepackageflexisym
usepackagewallpaper
usepackageblkarray
usetikzlibraryshapes.geometric
usetikzlibrarydecorations.markings
newenvironmenttightcenter
setlengthtopsep0pt
setlengthparskip0pt
begincenterendcenter
begindocument
A hemispherical bowl of radius $5.1$ cm contains water of depth $3.5$ cm, as shown below.
begincenter
begintikzpicture[scale=0.75]
%draw (-2.5,-1.65) arc (180:360:2.5 and 0.25);
%BIG CIRCLE
draw[thick](-3.2,+0.04) arc (180:360:3.2 and 1.05);
draw[thick](-3.2,+0.04) arc (3.2:180:-3.2 and 1.05);
%SMALL CIRLCE
draw[dashed](-2.85,-1.34) arc (180:360:2.85 and 0.8);
draw[dashed](-2.85,-1.34) arc (2.85:180:-2.85 and 1.05);
%triangle
%draw[gray,dashed](0,0) -- (+2.84,-1.52);
%draw[gray,dashed](0,0) -- (0,-1.52);
%draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
%
%draw (0,0) ++(0:2.8) arc (0:-45:2.8);
draw [thick,domain=-180:0] plot (3.2*cos(x), 3.2*sin(x)) ;
%node[below] at (0,-1.52) A;
%node[right] at (2.84,-1.52) B;
%
%draw [thick,fill=black] (0,-1.52) circle (0.04);
draw [thick,fill=black] (0,0) circle (0.04);
%draw [thick,fill=black] (2.81,-1.52) circle (0.04);
node[above] at (0,0.2) O;
%
%draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
%draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
%draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
endtikzpicture
endcenter
enddocument


Can someone suggest how to do the shading so I can complete this diagram?



Thank you.










share|improve this question

























    up vote
    6
    down vote

    favorite












    I am trying to draw the diagram below in latex
    What I want



    I got this far with the following code:
    progress



    documentclassarticle
    usepackage[margin=0.5in]geometry
    usepackagepgfplots
    renewcommandthesectionarabicsection
    usepackagemathtools
    usepackagecancel
    usepackagepgfplots
    usepackageamsmath
    newtheoremtheoremTHEOREM
    newtheoremproofPROOF
    usepackagetikz
    usepackageamssymb
    usetikzlibrarypatterns
    usepackagefancyhdr
    usepackagebigints
    usepackagecolor
    usepackagetcolorbox
    usepackagecolor,xcolor
    usepackagebooktabs,array
    usepackagehyperref
    usepackagegraphicx
    usetikzlibraryarrows
    usepackagepolynom
    usepackageflexisym
    usepackagewallpaper
    usepackageblkarray
    usetikzlibraryshapes.geometric
    usetikzlibrarydecorations.markings
    newenvironmenttightcenter
    setlengthtopsep0pt
    setlengthparskip0pt
    begincenterendcenter
    begindocument
    A hemispherical bowl of radius $5.1$ cm contains water of depth $3.5$ cm, as shown below.
    begincenter
    begintikzpicture[scale=0.75]
    %draw (-2.5,-1.65) arc (180:360:2.5 and 0.25);
    %BIG CIRCLE
    draw[thick](-3.2,+0.04) arc (180:360:3.2 and 1.05);
    draw[thick](-3.2,+0.04) arc (3.2:180:-3.2 and 1.05);
    %SMALL CIRLCE
    draw[dashed](-2.85,-1.34) arc (180:360:2.85 and 0.8);
    draw[dashed](-2.85,-1.34) arc (2.85:180:-2.85 and 1.05);
    %triangle
    %draw[gray,dashed](0,0) -- (+2.84,-1.52);
    %draw[gray,dashed](0,0) -- (0,-1.52);
    %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
    %
    %draw (0,0) ++(0:2.8) arc (0:-45:2.8);
    draw [thick,domain=-180:0] plot (3.2*cos(x), 3.2*sin(x)) ;
    %node[below] at (0,-1.52) A;
    %node[right] at (2.84,-1.52) B;
    %
    %draw [thick,fill=black] (0,-1.52) circle (0.04);
    draw [thick,fill=black] (0,0) circle (0.04);
    %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
    node[above] at (0,0.2) O;
    %
    %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
    %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
    %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
    endtikzpicture
    endcenter
    enddocument


    Can someone suggest how to do the shading so I can complete this diagram?



    Thank you.










    share|improve this question























      up vote
      6
      down vote

      favorite









      up vote
      6
      down vote

      favorite











      I am trying to draw the diagram below in latex
      What I want



      I got this far with the following code:
      progress



      documentclassarticle
      usepackage[margin=0.5in]geometry
      usepackagepgfplots
      renewcommandthesectionarabicsection
      usepackagemathtools
      usepackagecancel
      usepackagepgfplots
      usepackageamsmath
      newtheoremtheoremTHEOREM
      newtheoremproofPROOF
      usepackagetikz
      usepackageamssymb
      usetikzlibrarypatterns
      usepackagefancyhdr
      usepackagebigints
      usepackagecolor
      usepackagetcolorbox
      usepackagecolor,xcolor
      usepackagebooktabs,array
      usepackagehyperref
      usepackagegraphicx
      usetikzlibraryarrows
      usepackagepolynom
      usepackageflexisym
      usepackagewallpaper
      usepackageblkarray
      usetikzlibraryshapes.geometric
      usetikzlibrarydecorations.markings
      newenvironmenttightcenter
      setlengthtopsep0pt
      setlengthparskip0pt
      begincenterendcenter
      begindocument
      A hemispherical bowl of radius $5.1$ cm contains water of depth $3.5$ cm, as shown below.
      begincenter
      begintikzpicture[scale=0.75]
      %draw (-2.5,-1.65) arc (180:360:2.5 and 0.25);
      %BIG CIRCLE
      draw[thick](-3.2,+0.04) arc (180:360:3.2 and 1.05);
      draw[thick](-3.2,+0.04) arc (3.2:180:-3.2 and 1.05);
      %SMALL CIRLCE
      draw[dashed](-2.85,-1.34) arc (180:360:2.85 and 0.8);
      draw[dashed](-2.85,-1.34) arc (2.85:180:-2.85 and 1.05);
      %triangle
      %draw[gray,dashed](0,0) -- (+2.84,-1.52);
      %draw[gray,dashed](0,0) -- (0,-1.52);
      %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
      %
      %draw (0,0) ++(0:2.8) arc (0:-45:2.8);
      draw [thick,domain=-180:0] plot (3.2*cos(x), 3.2*sin(x)) ;
      %node[below] at (0,-1.52) A;
      %node[right] at (2.84,-1.52) B;
      %
      %draw [thick,fill=black] (0,-1.52) circle (0.04);
      draw [thick,fill=black] (0,0) circle (0.04);
      %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
      node[above] at (0,0.2) O;
      %
      %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
      %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
      %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
      endtikzpicture
      endcenter
      enddocument


      Can someone suggest how to do the shading so I can complete this diagram?



      Thank you.










      share|improve this question













      I am trying to draw the diagram below in latex
      What I want



      I got this far with the following code:
      progress



      documentclassarticle
      usepackage[margin=0.5in]geometry
      usepackagepgfplots
      renewcommandthesectionarabicsection
      usepackagemathtools
      usepackagecancel
      usepackagepgfplots
      usepackageamsmath
      newtheoremtheoremTHEOREM
      newtheoremproofPROOF
      usepackagetikz
      usepackageamssymb
      usetikzlibrarypatterns
      usepackagefancyhdr
      usepackagebigints
      usepackagecolor
      usepackagetcolorbox
      usepackagecolor,xcolor
      usepackagebooktabs,array
      usepackagehyperref
      usepackagegraphicx
      usetikzlibraryarrows
      usepackagepolynom
      usepackageflexisym
      usepackagewallpaper
      usepackageblkarray
      usetikzlibraryshapes.geometric
      usetikzlibrarydecorations.markings
      newenvironmenttightcenter
      setlengthtopsep0pt
      setlengthparskip0pt
      begincenterendcenter
      begindocument
      A hemispherical bowl of radius $5.1$ cm contains water of depth $3.5$ cm, as shown below.
      begincenter
      begintikzpicture[scale=0.75]
      %draw (-2.5,-1.65) arc (180:360:2.5 and 0.25);
      %BIG CIRCLE
      draw[thick](-3.2,+0.04) arc (180:360:3.2 and 1.05);
      draw[thick](-3.2,+0.04) arc (3.2:180:-3.2 and 1.05);
      %SMALL CIRLCE
      draw[dashed](-2.85,-1.34) arc (180:360:2.85 and 0.8);
      draw[dashed](-2.85,-1.34) arc (2.85:180:-2.85 and 1.05);
      %triangle
      %draw[gray,dashed](0,0) -- (+2.84,-1.52);
      %draw[gray,dashed](0,0) -- (0,-1.52);
      %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
      %
      %draw (0,0) ++(0:2.8) arc (0:-45:2.8);
      draw [thick,domain=-180:0] plot (3.2*cos(x), 3.2*sin(x)) ;
      %node[below] at (0,-1.52) A;
      %node[right] at (2.84,-1.52) B;
      %
      %draw [thick,fill=black] (0,-1.52) circle (0.04);
      draw [thick,fill=black] (0,0) circle (0.04);
      %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
      node[above] at (0,0.2) O;
      %
      %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
      %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
      %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
      endtikzpicture
      endcenter
      enddocument


      Can someone suggest how to do the shading so I can complete this diagram?



      Thank you.







      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 days ago









      Will Kim

      571216




      571216




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          documentclass[border=5pt,tikz]standalone
          usetikzlibraryarrows
          begindocument
          begintikzpicture[>=latex']
          draw[xshift=1.9cm,densely dashed,<->] (1,-1) -- (1,-1.5) node[midway,right] tiny $2,mathrmcm$;
          draw[densely dashed] (2,-1) --+ (.9,0);
          draw[densely dashed] (1.5,-1.5) --+ (1.4,0);
          beginscope
          clip[draw] (0,0) arc(180:360:1.5) (1.5,0) circle(1.5 and .5);
          draw[fill=gray!40] (.4,-1) arc(180:360:.73*1.5 and .2);
          draw[fill=gray!40,dashed] (2.59,-1) arc(0:180:.73*1.5 and .2);
          draw[gray!40] (.4,-1) -- (2.589,-1);
          fill[gray!40] (2.4*.73*1.5,-1) arc(0:-180:.73*1.5 and .6);
          draw (0,0) arc(180:360:1.5);
          draw[densely dashed,<->] (1.5,0) -- (3,0) node[midway,above] tiny $10,mathrmcm$;
          endscope
          draw (2.6,-1) arc(0:-180:.73*1.5 and .2);
          endtikzpicture
          enddocument


          Here is the output:



          Screenshot






          share|improve this answer






















          • @Harald_Hanche-Olsen: Thank you, I've got some bug, so that I can't format the code …
            – current_user
            2 days ago










          • In the preview it is alright, but in the answer it isn't anymore!
            – current_user
            2 days ago










          • @Harald_Hanche-Olsen: Sorry, didn't want that. I fixed my code, so could you please do it one more time for me?
            – current_user
            2 days ago











          • @Harald_Hanche-Olsen: imgur.com/a/YxcmzdZ
            – current_user
            2 days ago






          • 1




            Looks beautiful, thank you!
            – Will Kim
            2 days ago

















          up vote
          4
          down vote













          I know I'm quite late to the party, but I took this question as an opportunity to learn some more on the projection of spheres, and to re-use my answer here. I created a partially filled sphere, with a predetermined level waterlevel which should be between 0 and 1, which is projected with a certain elevation angle el which should be between 0 and 90. The best results are obtained with 0.2 < waterlevel < 1 and 10 < el < 40. In the following example el is set to 20 and the waterlevel to 0.5.



          enter image description here



          Of course, an animation can be made easily (with el still set to 20):



          enter image description here



          Disclaimer

          The projection of the hemisphere is correct, as is the projection of the water surface. The shading of the water is not completely correct. The 'front view', the part of the water that is touching the sphere, is an approximation, but that is invisible with waterlevel above approximately 0.35.



          MWE:



          documentclass[tikz,margin=2mm]standalone

          usetikzlibrary3d

          % small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
          makeatletter
          tikzoptioncanvas is xy plane at z%
          deftikz@plane@originpgfpointxyz00#1%
          deftikz@plane@xpgfpointxyz10#1%
          deftikz@plane@ypgfpointxyz01#1%
          tikz@canvas@is@plane

          % view=<azimuth>,<elevation> key https://tex.stackexchange.com/a/447401/74459
          tikzset
          view/.code args=#1,#2%
          % Set elevation and azimuth angles
          pgfmathsetmacroview@az#1
          pgfmathsetmacroview@el#2
          % Calculate projections of rotation matrix
          pgfmathsetmacroxvec@xcos(view@az)
          pgfmathsetmacroxvec@y-sin(view@az)*sin(view@el)
          pgfmathsetmacroyvec@xsin(view@az)
          pgfmathsetmacroyvec@ycos(view@az)*sin(view@el)
          pgfmathsetmacrozvec@x0
          pgfmathsetmacrozvec@ycos(view@el)
          % Set base vectors
          pgfsetxvecpgfpointxvec@x cmxvec@y cm
          pgfsetyvecpgfpointyvec@x cmyvec@y cm
          pgfsetzvecpgfpointzvec@x cmzvec@y cm
          ,

          makeatother

          begindocument

          begintikzpicture[scale=0.75,water shading/.style=ball color=cyan!50!white,fill opacity=0.5]

          % PRE-CALCULATIONS
          pgfmathsetmacroel20
          pgfmathsetmacroradius3.2
          pgfmathsetmacrosmallradiussin(el)*radius
          pgfmathsetmacrowaterlevel0.5 % between 0 and 1
          pgfmathsetmacrowaterradiussin(acos(-1+waterlevel))*radius
          pgfmathsetmacrowatersmallradiussin(el)*waterradius

          %SHADING
          % Two shading paths to mimic the different light refraction of the front and the surface
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (180:0:waterradius and watersmallradius) -- cycle;
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (-180:0:waterradius and watersmallradius) -- cycle;

          %BIG CIRCLE
          % Due to the 'view' key, a circle with a fixed radius becomes an ellipse
          draw[thick,view=0,el,canvas is xy plane at z=0] (0,0) circle (radius);
          % No matter what the elevation of the view is, a (half-)sphere is always projected as a (half-)circle.
          draw[thick] (0,0) ++(0:radius) arc (0:-180:radius);
          %SMALL CIRLCE
          % Again using the 'view' key, the small circle can be drawn as two seperate arcs with fixed radius.
          draw[dashed,view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:180:waterradius);
          draw[view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:-180:waterradius);

          %triangle
          %draw[gray,dashed](0,0) -- (+2.84,-1.52);
          %draw[gray,dashed](0,0) -- (0,-1.52);
          %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
          %
          %node[below] at (0,-1.52) A;
          %node[right] at (2.84,-1.52) B;
          %
          %draw [thick,fill=black] (0,-1.52) circle (0.04);
          draw [thick,fill=black] (0,0) circle (0.04);
          %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
          node[above] at (0,0.2) O;
          %
          %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
          %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
          %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
          endtikzpicture

          enddocument


          MWE animation:



          documentclass[tikz,margin=2mm]standalone

          usetikzlibrary3d

          % small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
          makeatletter
          tikzoptioncanvas is xy plane at z%
          deftikz@plane@originpgfpointxyz00#1%
          deftikz@plane@xpgfpointxyz10#1%
          deftikz@plane@ypgfpointxyz01#1%
          tikz@canvas@is@plane

          % view=<azimuth>,<elevation> key https://tex.stackexchange.com/a/447401/74459
          tikzset
          view/.code args=#1,#2%
          % Set elevation and azimuth angles
          pgfmathsetmacroview@az#1
          pgfmathsetmacroview@el#2
          % Calculate projections of rotation matrix
          pgfmathsetmacroxvec@xcos(view@az)
          pgfmathsetmacroxvec@y-sin(view@az)*sin(view@el)
          pgfmathsetmacroyvec@xsin(view@az)
          pgfmathsetmacroyvec@ycos(view@az)*sin(view@el)
          pgfmathsetmacrozvec@x0
          pgfmathsetmacrozvec@ycos(view@el)
          % Set base vectors
          pgfsetxvecpgfpointxvec@x cmxvec@y cm
          pgfsetyvecpgfpointyvec@x cmyvec@y cm
          pgfsetzvecpgfpointzvec@x cmzvec@y cm
          ,

          makeatother

          begindocument

          pgfmathsetmacroel20

          foreach fr [evaluate=fr as wl using fr/100] in 0,5,...,100
          begintikzpicture[scale=0.75,water shading/.style=ball color=cyan!50!white,fill opacity=0.5]

          % PRE-CALCULATIONS
          pgfmathsetmacroradius3.2
          pgfmathsetmacrosmallradiussin(el)*radius
          pgfmathsetmacrowaterlevelwl % between 0 and 1
          pgfmathsetmacrowaterradiussin(acos(-1+waterlevel))*radius
          pgfmathsetmacrowatersmallradiussin(el)*waterradius

          %CLIPPING
          % For the animation only (I think this is required because arcs are drawn as Bezier curves with control points that contribute to the bounding box)
          clip (-1.2*radius,-1.2*radius) rectangle (1.2*radius,1.5*smallradius);

          %SHADING
          % Two shading paths to mimic the different light refraction of the front and the surface
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (180:0:waterradius and watersmallradius) -- cycle;
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (-180:0:waterradius and watersmallradius) -- cycle;

          %BIG CIRCLE
          % Due to the 'view' key, a circle with a fixed radius becomes an ellipse
          draw[thick,view=0,el,canvas is xy plane at z=0] (0,0) circle (radius);
          % No matter what the elevation of the view is, a (half-)sphere is always projected as a (half-)circle.
          draw[thick] (0,0) ++(0:radius) arc (0:-180:radius);
          %SMALL CIRLCE
          % Again using the 'view' key, the small circle can be drawn as two seperate arcs with fixed radius.
          draw[dashed,view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:180:waterradius);
          draw[view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:-180:waterradius);

          %triangle
          %draw[gray,dashed](0,0) -- (+2.84,-1.52);
          %draw[gray,dashed](0,0) -- (0,-1.52);
          %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
          %
          %node[below] at (0,-1.52) A;
          %node[right] at (2.84,-1.52) B;
          %
          %draw [thick,fill=black] (0,-1.52) circle (0.04);
          draw [thick,fill=black] (0,0) circle (0.04);
          %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
          node[above] at (0,0.2) O;
          %
          %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
          %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
          %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
          endtikzpicture

          enddocument





          share|improve this answer




















          • This is beautiful. Thank you so much
            – Will Kim
            yesterday










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "85"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f450223%2fwater-inside-a-hemispherical-bowl%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          documentclass[border=5pt,tikz]standalone
          usetikzlibraryarrows
          begindocument
          begintikzpicture[>=latex']
          draw[xshift=1.9cm,densely dashed,<->] (1,-1) -- (1,-1.5) node[midway,right] tiny $2,mathrmcm$;
          draw[densely dashed] (2,-1) --+ (.9,0);
          draw[densely dashed] (1.5,-1.5) --+ (1.4,0);
          beginscope
          clip[draw] (0,0) arc(180:360:1.5) (1.5,0) circle(1.5 and .5);
          draw[fill=gray!40] (.4,-1) arc(180:360:.73*1.5 and .2);
          draw[fill=gray!40,dashed] (2.59,-1) arc(0:180:.73*1.5 and .2);
          draw[gray!40] (.4,-1) -- (2.589,-1);
          fill[gray!40] (2.4*.73*1.5,-1) arc(0:-180:.73*1.5 and .6);
          draw (0,0) arc(180:360:1.5);
          draw[densely dashed,<->] (1.5,0) -- (3,0) node[midway,above] tiny $10,mathrmcm$;
          endscope
          draw (2.6,-1) arc(0:-180:.73*1.5 and .2);
          endtikzpicture
          enddocument


          Here is the output:



          Screenshot






          share|improve this answer






















          • @Harald_Hanche-Olsen: Thank you, I've got some bug, so that I can't format the code …
            – current_user
            2 days ago










          • In the preview it is alright, but in the answer it isn't anymore!
            – current_user
            2 days ago










          • @Harald_Hanche-Olsen: Sorry, didn't want that. I fixed my code, so could you please do it one more time for me?
            – current_user
            2 days ago











          • @Harald_Hanche-Olsen: imgur.com/a/YxcmzdZ
            – current_user
            2 days ago






          • 1




            Looks beautiful, thank you!
            – Will Kim
            2 days ago














          up vote
          3
          down vote



          accepted










          documentclass[border=5pt,tikz]standalone
          usetikzlibraryarrows
          begindocument
          begintikzpicture[>=latex']
          draw[xshift=1.9cm,densely dashed,<->] (1,-1) -- (1,-1.5) node[midway,right] tiny $2,mathrmcm$;
          draw[densely dashed] (2,-1) --+ (.9,0);
          draw[densely dashed] (1.5,-1.5) --+ (1.4,0);
          beginscope
          clip[draw] (0,0) arc(180:360:1.5) (1.5,0) circle(1.5 and .5);
          draw[fill=gray!40] (.4,-1) arc(180:360:.73*1.5 and .2);
          draw[fill=gray!40,dashed] (2.59,-1) arc(0:180:.73*1.5 and .2);
          draw[gray!40] (.4,-1) -- (2.589,-1);
          fill[gray!40] (2.4*.73*1.5,-1) arc(0:-180:.73*1.5 and .6);
          draw (0,0) arc(180:360:1.5);
          draw[densely dashed,<->] (1.5,0) -- (3,0) node[midway,above] tiny $10,mathrmcm$;
          endscope
          draw (2.6,-1) arc(0:-180:.73*1.5 and .2);
          endtikzpicture
          enddocument


          Here is the output:



          Screenshot






          share|improve this answer






















          • @Harald_Hanche-Olsen: Thank you, I've got some bug, so that I can't format the code …
            – current_user
            2 days ago










          • In the preview it is alright, but in the answer it isn't anymore!
            – current_user
            2 days ago










          • @Harald_Hanche-Olsen: Sorry, didn't want that. I fixed my code, so could you please do it one more time for me?
            – current_user
            2 days ago











          • @Harald_Hanche-Olsen: imgur.com/a/YxcmzdZ
            – current_user
            2 days ago






          • 1




            Looks beautiful, thank you!
            – Will Kim
            2 days ago












          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          documentclass[border=5pt,tikz]standalone
          usetikzlibraryarrows
          begindocument
          begintikzpicture[>=latex']
          draw[xshift=1.9cm,densely dashed,<->] (1,-1) -- (1,-1.5) node[midway,right] tiny $2,mathrmcm$;
          draw[densely dashed] (2,-1) --+ (.9,0);
          draw[densely dashed] (1.5,-1.5) --+ (1.4,0);
          beginscope
          clip[draw] (0,0) arc(180:360:1.5) (1.5,0) circle(1.5 and .5);
          draw[fill=gray!40] (.4,-1) arc(180:360:.73*1.5 and .2);
          draw[fill=gray!40,dashed] (2.59,-1) arc(0:180:.73*1.5 and .2);
          draw[gray!40] (.4,-1) -- (2.589,-1);
          fill[gray!40] (2.4*.73*1.5,-1) arc(0:-180:.73*1.5 and .6);
          draw (0,0) arc(180:360:1.5);
          draw[densely dashed,<->] (1.5,0) -- (3,0) node[midway,above] tiny $10,mathrmcm$;
          endscope
          draw (2.6,-1) arc(0:-180:.73*1.5 and .2);
          endtikzpicture
          enddocument


          Here is the output:



          Screenshot






          share|improve this answer














          documentclass[border=5pt,tikz]standalone
          usetikzlibraryarrows
          begindocument
          begintikzpicture[>=latex']
          draw[xshift=1.9cm,densely dashed,<->] (1,-1) -- (1,-1.5) node[midway,right] tiny $2,mathrmcm$;
          draw[densely dashed] (2,-1) --+ (.9,0);
          draw[densely dashed] (1.5,-1.5) --+ (1.4,0);
          beginscope
          clip[draw] (0,0) arc(180:360:1.5) (1.5,0) circle(1.5 and .5);
          draw[fill=gray!40] (.4,-1) arc(180:360:.73*1.5 and .2);
          draw[fill=gray!40,dashed] (2.59,-1) arc(0:180:.73*1.5 and .2);
          draw[gray!40] (.4,-1) -- (2.589,-1);
          fill[gray!40] (2.4*.73*1.5,-1) arc(0:-180:.73*1.5 and .6);
          draw (0,0) arc(180:360:1.5);
          draw[densely dashed,<->] (1.5,0) -- (3,0) node[midway,above] tiny $10,mathrmcm$;
          endscope
          draw (2.6,-1) arc(0:-180:.73*1.5 and .2);
          endtikzpicture
          enddocument


          Here is the output:



          Screenshot







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago









          Harald Hanche-Olsen

          12.5k24560




          12.5k24560










          answered 2 days ago









          current_user

          2,5741428




          2,5741428











          • @Harald_Hanche-Olsen: Thank you, I've got some bug, so that I can't format the code …
            – current_user
            2 days ago










          • In the preview it is alright, but in the answer it isn't anymore!
            – current_user
            2 days ago










          • @Harald_Hanche-Olsen: Sorry, didn't want that. I fixed my code, so could you please do it one more time for me?
            – current_user
            2 days ago











          • @Harald_Hanche-Olsen: imgur.com/a/YxcmzdZ
            – current_user
            2 days ago






          • 1




            Looks beautiful, thank you!
            – Will Kim
            2 days ago
















          • @Harald_Hanche-Olsen: Thank you, I've got some bug, so that I can't format the code …
            – current_user
            2 days ago










          • In the preview it is alright, but in the answer it isn't anymore!
            – current_user
            2 days ago










          • @Harald_Hanche-Olsen: Sorry, didn't want that. I fixed my code, so could you please do it one more time for me?
            – current_user
            2 days ago











          • @Harald_Hanche-Olsen: imgur.com/a/YxcmzdZ
            – current_user
            2 days ago






          • 1




            Looks beautiful, thank you!
            – Will Kim
            2 days ago















          @Harald_Hanche-Olsen: Thank you, I've got some bug, so that I can't format the code …
          – current_user
          2 days ago




          @Harald_Hanche-Olsen: Thank you, I've got some bug, so that I can't format the code …
          – current_user
          2 days ago












          In the preview it is alright, but in the answer it isn't anymore!
          – current_user
          2 days ago




          In the preview it is alright, but in the answer it isn't anymore!
          – current_user
          2 days ago












          @Harald_Hanche-Olsen: Sorry, didn't want that. I fixed my code, so could you please do it one more time for me?
          – current_user
          2 days ago





          @Harald_Hanche-Olsen: Sorry, didn't want that. I fixed my code, so could you please do it one more time for me?
          – current_user
          2 days ago













          @Harald_Hanche-Olsen: imgur.com/a/YxcmzdZ
          – current_user
          2 days ago




          @Harald_Hanche-Olsen: imgur.com/a/YxcmzdZ
          – current_user
          2 days ago




          1




          1




          Looks beautiful, thank you!
          – Will Kim
          2 days ago




          Looks beautiful, thank you!
          – Will Kim
          2 days ago










          up vote
          4
          down vote













          I know I'm quite late to the party, but I took this question as an opportunity to learn some more on the projection of spheres, and to re-use my answer here. I created a partially filled sphere, with a predetermined level waterlevel which should be between 0 and 1, which is projected with a certain elevation angle el which should be between 0 and 90. The best results are obtained with 0.2 < waterlevel < 1 and 10 < el < 40. In the following example el is set to 20 and the waterlevel to 0.5.



          enter image description here



          Of course, an animation can be made easily (with el still set to 20):



          enter image description here



          Disclaimer

          The projection of the hemisphere is correct, as is the projection of the water surface. The shading of the water is not completely correct. The 'front view', the part of the water that is touching the sphere, is an approximation, but that is invisible with waterlevel above approximately 0.35.



          MWE:



          documentclass[tikz,margin=2mm]standalone

          usetikzlibrary3d

          % small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
          makeatletter
          tikzoptioncanvas is xy plane at z%
          deftikz@plane@originpgfpointxyz00#1%
          deftikz@plane@xpgfpointxyz10#1%
          deftikz@plane@ypgfpointxyz01#1%
          tikz@canvas@is@plane

          % view=<azimuth>,<elevation> key https://tex.stackexchange.com/a/447401/74459
          tikzset
          view/.code args=#1,#2%
          % Set elevation and azimuth angles
          pgfmathsetmacroview@az#1
          pgfmathsetmacroview@el#2
          % Calculate projections of rotation matrix
          pgfmathsetmacroxvec@xcos(view@az)
          pgfmathsetmacroxvec@y-sin(view@az)*sin(view@el)
          pgfmathsetmacroyvec@xsin(view@az)
          pgfmathsetmacroyvec@ycos(view@az)*sin(view@el)
          pgfmathsetmacrozvec@x0
          pgfmathsetmacrozvec@ycos(view@el)
          % Set base vectors
          pgfsetxvecpgfpointxvec@x cmxvec@y cm
          pgfsetyvecpgfpointyvec@x cmyvec@y cm
          pgfsetzvecpgfpointzvec@x cmzvec@y cm
          ,

          makeatother

          begindocument

          begintikzpicture[scale=0.75,water shading/.style=ball color=cyan!50!white,fill opacity=0.5]

          % PRE-CALCULATIONS
          pgfmathsetmacroel20
          pgfmathsetmacroradius3.2
          pgfmathsetmacrosmallradiussin(el)*radius
          pgfmathsetmacrowaterlevel0.5 % between 0 and 1
          pgfmathsetmacrowaterradiussin(acos(-1+waterlevel))*radius
          pgfmathsetmacrowatersmallradiussin(el)*waterradius

          %SHADING
          % Two shading paths to mimic the different light refraction of the front and the surface
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (180:0:waterradius and watersmallradius) -- cycle;
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (-180:0:waterradius and watersmallradius) -- cycle;

          %BIG CIRCLE
          % Due to the 'view' key, a circle with a fixed radius becomes an ellipse
          draw[thick,view=0,el,canvas is xy plane at z=0] (0,0) circle (radius);
          % No matter what the elevation of the view is, a (half-)sphere is always projected as a (half-)circle.
          draw[thick] (0,0) ++(0:radius) arc (0:-180:radius);
          %SMALL CIRLCE
          % Again using the 'view' key, the small circle can be drawn as two seperate arcs with fixed radius.
          draw[dashed,view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:180:waterradius);
          draw[view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:-180:waterradius);

          %triangle
          %draw[gray,dashed](0,0) -- (+2.84,-1.52);
          %draw[gray,dashed](0,0) -- (0,-1.52);
          %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
          %
          %node[below] at (0,-1.52) A;
          %node[right] at (2.84,-1.52) B;
          %
          %draw [thick,fill=black] (0,-1.52) circle (0.04);
          draw [thick,fill=black] (0,0) circle (0.04);
          %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
          node[above] at (0,0.2) O;
          %
          %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
          %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
          %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
          endtikzpicture

          enddocument


          MWE animation:



          documentclass[tikz,margin=2mm]standalone

          usetikzlibrary3d

          % small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
          makeatletter
          tikzoptioncanvas is xy plane at z%
          deftikz@plane@originpgfpointxyz00#1%
          deftikz@plane@xpgfpointxyz10#1%
          deftikz@plane@ypgfpointxyz01#1%
          tikz@canvas@is@plane

          % view=<azimuth>,<elevation> key https://tex.stackexchange.com/a/447401/74459
          tikzset
          view/.code args=#1,#2%
          % Set elevation and azimuth angles
          pgfmathsetmacroview@az#1
          pgfmathsetmacroview@el#2
          % Calculate projections of rotation matrix
          pgfmathsetmacroxvec@xcos(view@az)
          pgfmathsetmacroxvec@y-sin(view@az)*sin(view@el)
          pgfmathsetmacroyvec@xsin(view@az)
          pgfmathsetmacroyvec@ycos(view@az)*sin(view@el)
          pgfmathsetmacrozvec@x0
          pgfmathsetmacrozvec@ycos(view@el)
          % Set base vectors
          pgfsetxvecpgfpointxvec@x cmxvec@y cm
          pgfsetyvecpgfpointyvec@x cmyvec@y cm
          pgfsetzvecpgfpointzvec@x cmzvec@y cm
          ,

          makeatother

          begindocument

          pgfmathsetmacroel20

          foreach fr [evaluate=fr as wl using fr/100] in 0,5,...,100
          begintikzpicture[scale=0.75,water shading/.style=ball color=cyan!50!white,fill opacity=0.5]

          % PRE-CALCULATIONS
          pgfmathsetmacroradius3.2
          pgfmathsetmacrosmallradiussin(el)*radius
          pgfmathsetmacrowaterlevelwl % between 0 and 1
          pgfmathsetmacrowaterradiussin(acos(-1+waterlevel))*radius
          pgfmathsetmacrowatersmallradiussin(el)*waterradius

          %CLIPPING
          % For the animation only (I think this is required because arcs are drawn as Bezier curves with control points that contribute to the bounding box)
          clip (-1.2*radius,-1.2*radius) rectangle (1.2*radius,1.5*smallradius);

          %SHADING
          % Two shading paths to mimic the different light refraction of the front and the surface
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (180:0:waterradius and watersmallradius) -- cycle;
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (-180:0:waterradius and watersmallradius) -- cycle;

          %BIG CIRCLE
          % Due to the 'view' key, a circle with a fixed radius becomes an ellipse
          draw[thick,view=0,el,canvas is xy plane at z=0] (0,0) circle (radius);
          % No matter what the elevation of the view is, a (half-)sphere is always projected as a (half-)circle.
          draw[thick] (0,0) ++(0:radius) arc (0:-180:radius);
          %SMALL CIRLCE
          % Again using the 'view' key, the small circle can be drawn as two seperate arcs with fixed radius.
          draw[dashed,view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:180:waterradius);
          draw[view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:-180:waterradius);

          %triangle
          %draw[gray,dashed](0,0) -- (+2.84,-1.52);
          %draw[gray,dashed](0,0) -- (0,-1.52);
          %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
          %
          %node[below] at (0,-1.52) A;
          %node[right] at (2.84,-1.52) B;
          %
          %draw [thick,fill=black] (0,-1.52) circle (0.04);
          draw [thick,fill=black] (0,0) circle (0.04);
          %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
          node[above] at (0,0.2) O;
          %
          %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
          %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
          %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
          endtikzpicture

          enddocument





          share|improve this answer




















          • This is beautiful. Thank you so much
            – Will Kim
            yesterday














          up vote
          4
          down vote













          I know I'm quite late to the party, but I took this question as an opportunity to learn some more on the projection of spheres, and to re-use my answer here. I created a partially filled sphere, with a predetermined level waterlevel which should be between 0 and 1, which is projected with a certain elevation angle el which should be between 0 and 90. The best results are obtained with 0.2 < waterlevel < 1 and 10 < el < 40. In the following example el is set to 20 and the waterlevel to 0.5.



          enter image description here



          Of course, an animation can be made easily (with el still set to 20):



          enter image description here



          Disclaimer

          The projection of the hemisphere is correct, as is the projection of the water surface. The shading of the water is not completely correct. The 'front view', the part of the water that is touching the sphere, is an approximation, but that is invisible with waterlevel above approximately 0.35.



          MWE:



          documentclass[tikz,margin=2mm]standalone

          usetikzlibrary3d

          % small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
          makeatletter
          tikzoptioncanvas is xy plane at z%
          deftikz@plane@originpgfpointxyz00#1%
          deftikz@plane@xpgfpointxyz10#1%
          deftikz@plane@ypgfpointxyz01#1%
          tikz@canvas@is@plane

          % view=<azimuth>,<elevation> key https://tex.stackexchange.com/a/447401/74459
          tikzset
          view/.code args=#1,#2%
          % Set elevation and azimuth angles
          pgfmathsetmacroview@az#1
          pgfmathsetmacroview@el#2
          % Calculate projections of rotation matrix
          pgfmathsetmacroxvec@xcos(view@az)
          pgfmathsetmacroxvec@y-sin(view@az)*sin(view@el)
          pgfmathsetmacroyvec@xsin(view@az)
          pgfmathsetmacroyvec@ycos(view@az)*sin(view@el)
          pgfmathsetmacrozvec@x0
          pgfmathsetmacrozvec@ycos(view@el)
          % Set base vectors
          pgfsetxvecpgfpointxvec@x cmxvec@y cm
          pgfsetyvecpgfpointyvec@x cmyvec@y cm
          pgfsetzvecpgfpointzvec@x cmzvec@y cm
          ,

          makeatother

          begindocument

          begintikzpicture[scale=0.75,water shading/.style=ball color=cyan!50!white,fill opacity=0.5]

          % PRE-CALCULATIONS
          pgfmathsetmacroel20
          pgfmathsetmacroradius3.2
          pgfmathsetmacrosmallradiussin(el)*radius
          pgfmathsetmacrowaterlevel0.5 % between 0 and 1
          pgfmathsetmacrowaterradiussin(acos(-1+waterlevel))*radius
          pgfmathsetmacrowatersmallradiussin(el)*waterradius

          %SHADING
          % Two shading paths to mimic the different light refraction of the front and the surface
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (180:0:waterradius and watersmallradius) -- cycle;
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (-180:0:waterradius and watersmallradius) -- cycle;

          %BIG CIRCLE
          % Due to the 'view' key, a circle with a fixed radius becomes an ellipse
          draw[thick,view=0,el,canvas is xy plane at z=0] (0,0) circle (radius);
          % No matter what the elevation of the view is, a (half-)sphere is always projected as a (half-)circle.
          draw[thick] (0,0) ++(0:radius) arc (0:-180:radius);
          %SMALL CIRLCE
          % Again using the 'view' key, the small circle can be drawn as two seperate arcs with fixed radius.
          draw[dashed,view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:180:waterradius);
          draw[view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:-180:waterradius);

          %triangle
          %draw[gray,dashed](0,0) -- (+2.84,-1.52);
          %draw[gray,dashed](0,0) -- (0,-1.52);
          %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
          %
          %node[below] at (0,-1.52) A;
          %node[right] at (2.84,-1.52) B;
          %
          %draw [thick,fill=black] (0,-1.52) circle (0.04);
          draw [thick,fill=black] (0,0) circle (0.04);
          %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
          node[above] at (0,0.2) O;
          %
          %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
          %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
          %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
          endtikzpicture

          enddocument


          MWE animation:



          documentclass[tikz,margin=2mm]standalone

          usetikzlibrary3d

          % small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
          makeatletter
          tikzoptioncanvas is xy plane at z%
          deftikz@plane@originpgfpointxyz00#1%
          deftikz@plane@xpgfpointxyz10#1%
          deftikz@plane@ypgfpointxyz01#1%
          tikz@canvas@is@plane

          % view=<azimuth>,<elevation> key https://tex.stackexchange.com/a/447401/74459
          tikzset
          view/.code args=#1,#2%
          % Set elevation and azimuth angles
          pgfmathsetmacroview@az#1
          pgfmathsetmacroview@el#2
          % Calculate projections of rotation matrix
          pgfmathsetmacroxvec@xcos(view@az)
          pgfmathsetmacroxvec@y-sin(view@az)*sin(view@el)
          pgfmathsetmacroyvec@xsin(view@az)
          pgfmathsetmacroyvec@ycos(view@az)*sin(view@el)
          pgfmathsetmacrozvec@x0
          pgfmathsetmacrozvec@ycos(view@el)
          % Set base vectors
          pgfsetxvecpgfpointxvec@x cmxvec@y cm
          pgfsetyvecpgfpointyvec@x cmyvec@y cm
          pgfsetzvecpgfpointzvec@x cmzvec@y cm
          ,

          makeatother

          begindocument

          pgfmathsetmacroel20

          foreach fr [evaluate=fr as wl using fr/100] in 0,5,...,100
          begintikzpicture[scale=0.75,water shading/.style=ball color=cyan!50!white,fill opacity=0.5]

          % PRE-CALCULATIONS
          pgfmathsetmacroradius3.2
          pgfmathsetmacrosmallradiussin(el)*radius
          pgfmathsetmacrowaterlevelwl % between 0 and 1
          pgfmathsetmacrowaterradiussin(acos(-1+waterlevel))*radius
          pgfmathsetmacrowatersmallradiussin(el)*waterradius

          %CLIPPING
          % For the animation only (I think this is required because arcs are drawn as Bezier curves with control points that contribute to the bounding box)
          clip (-1.2*radius,-1.2*radius) rectangle (1.2*radius,1.5*smallradius);

          %SHADING
          % Two shading paths to mimic the different light refraction of the front and the surface
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (180:0:waterradius and watersmallradius) -- cycle;
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (-180:0:waterradius and watersmallradius) -- cycle;

          %BIG CIRCLE
          % Due to the 'view' key, a circle with a fixed radius becomes an ellipse
          draw[thick,view=0,el,canvas is xy plane at z=0] (0,0) circle (radius);
          % No matter what the elevation of the view is, a (half-)sphere is always projected as a (half-)circle.
          draw[thick] (0,0) ++(0:radius) arc (0:-180:radius);
          %SMALL CIRLCE
          % Again using the 'view' key, the small circle can be drawn as two seperate arcs with fixed radius.
          draw[dashed,view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:180:waterradius);
          draw[view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:-180:waterradius);

          %triangle
          %draw[gray,dashed](0,0) -- (+2.84,-1.52);
          %draw[gray,dashed](0,0) -- (0,-1.52);
          %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
          %
          %node[below] at (0,-1.52) A;
          %node[right] at (2.84,-1.52) B;
          %
          %draw [thick,fill=black] (0,-1.52) circle (0.04);
          draw [thick,fill=black] (0,0) circle (0.04);
          %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
          node[above] at (0,0.2) O;
          %
          %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
          %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
          %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
          endtikzpicture

          enddocument





          share|improve this answer




















          • This is beautiful. Thank you so much
            – Will Kim
            yesterday












          up vote
          4
          down vote










          up vote
          4
          down vote









          I know I'm quite late to the party, but I took this question as an opportunity to learn some more on the projection of spheres, and to re-use my answer here. I created a partially filled sphere, with a predetermined level waterlevel which should be between 0 and 1, which is projected with a certain elevation angle el which should be between 0 and 90. The best results are obtained with 0.2 < waterlevel < 1 and 10 < el < 40. In the following example el is set to 20 and the waterlevel to 0.5.



          enter image description here



          Of course, an animation can be made easily (with el still set to 20):



          enter image description here



          Disclaimer

          The projection of the hemisphere is correct, as is the projection of the water surface. The shading of the water is not completely correct. The 'front view', the part of the water that is touching the sphere, is an approximation, but that is invisible with waterlevel above approximately 0.35.



          MWE:



          documentclass[tikz,margin=2mm]standalone

          usetikzlibrary3d

          % small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
          makeatletter
          tikzoptioncanvas is xy plane at z%
          deftikz@plane@originpgfpointxyz00#1%
          deftikz@plane@xpgfpointxyz10#1%
          deftikz@plane@ypgfpointxyz01#1%
          tikz@canvas@is@plane

          % view=<azimuth>,<elevation> key https://tex.stackexchange.com/a/447401/74459
          tikzset
          view/.code args=#1,#2%
          % Set elevation and azimuth angles
          pgfmathsetmacroview@az#1
          pgfmathsetmacroview@el#2
          % Calculate projections of rotation matrix
          pgfmathsetmacroxvec@xcos(view@az)
          pgfmathsetmacroxvec@y-sin(view@az)*sin(view@el)
          pgfmathsetmacroyvec@xsin(view@az)
          pgfmathsetmacroyvec@ycos(view@az)*sin(view@el)
          pgfmathsetmacrozvec@x0
          pgfmathsetmacrozvec@ycos(view@el)
          % Set base vectors
          pgfsetxvecpgfpointxvec@x cmxvec@y cm
          pgfsetyvecpgfpointyvec@x cmyvec@y cm
          pgfsetzvecpgfpointzvec@x cmzvec@y cm
          ,

          makeatother

          begindocument

          begintikzpicture[scale=0.75,water shading/.style=ball color=cyan!50!white,fill opacity=0.5]

          % PRE-CALCULATIONS
          pgfmathsetmacroel20
          pgfmathsetmacroradius3.2
          pgfmathsetmacrosmallradiussin(el)*radius
          pgfmathsetmacrowaterlevel0.5 % between 0 and 1
          pgfmathsetmacrowaterradiussin(acos(-1+waterlevel))*radius
          pgfmathsetmacrowatersmallradiussin(el)*waterradius

          %SHADING
          % Two shading paths to mimic the different light refraction of the front and the surface
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (180:0:waterradius and watersmallradius) -- cycle;
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (-180:0:waterradius and watersmallradius) -- cycle;

          %BIG CIRCLE
          % Due to the 'view' key, a circle with a fixed radius becomes an ellipse
          draw[thick,view=0,el,canvas is xy plane at z=0] (0,0) circle (radius);
          % No matter what the elevation of the view is, a (half-)sphere is always projected as a (half-)circle.
          draw[thick] (0,0) ++(0:radius) arc (0:-180:radius);
          %SMALL CIRLCE
          % Again using the 'view' key, the small circle can be drawn as two seperate arcs with fixed radius.
          draw[dashed,view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:180:waterradius);
          draw[view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:-180:waterradius);

          %triangle
          %draw[gray,dashed](0,0) -- (+2.84,-1.52);
          %draw[gray,dashed](0,0) -- (0,-1.52);
          %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
          %
          %node[below] at (0,-1.52) A;
          %node[right] at (2.84,-1.52) B;
          %
          %draw [thick,fill=black] (0,-1.52) circle (0.04);
          draw [thick,fill=black] (0,0) circle (0.04);
          %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
          node[above] at (0,0.2) O;
          %
          %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
          %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
          %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
          endtikzpicture

          enddocument


          MWE animation:



          documentclass[tikz,margin=2mm]standalone

          usetikzlibrary3d

          % small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
          makeatletter
          tikzoptioncanvas is xy plane at z%
          deftikz@plane@originpgfpointxyz00#1%
          deftikz@plane@xpgfpointxyz10#1%
          deftikz@plane@ypgfpointxyz01#1%
          tikz@canvas@is@plane

          % view=<azimuth>,<elevation> key https://tex.stackexchange.com/a/447401/74459
          tikzset
          view/.code args=#1,#2%
          % Set elevation and azimuth angles
          pgfmathsetmacroview@az#1
          pgfmathsetmacroview@el#2
          % Calculate projections of rotation matrix
          pgfmathsetmacroxvec@xcos(view@az)
          pgfmathsetmacroxvec@y-sin(view@az)*sin(view@el)
          pgfmathsetmacroyvec@xsin(view@az)
          pgfmathsetmacroyvec@ycos(view@az)*sin(view@el)
          pgfmathsetmacrozvec@x0
          pgfmathsetmacrozvec@ycos(view@el)
          % Set base vectors
          pgfsetxvecpgfpointxvec@x cmxvec@y cm
          pgfsetyvecpgfpointyvec@x cmyvec@y cm
          pgfsetzvecpgfpointzvec@x cmzvec@y cm
          ,

          makeatother

          begindocument

          pgfmathsetmacroel20

          foreach fr [evaluate=fr as wl using fr/100] in 0,5,...,100
          begintikzpicture[scale=0.75,water shading/.style=ball color=cyan!50!white,fill opacity=0.5]

          % PRE-CALCULATIONS
          pgfmathsetmacroradius3.2
          pgfmathsetmacrosmallradiussin(el)*radius
          pgfmathsetmacrowaterlevelwl % between 0 and 1
          pgfmathsetmacrowaterradiussin(acos(-1+waterlevel))*radius
          pgfmathsetmacrowatersmallradiussin(el)*waterradius

          %CLIPPING
          % For the animation only (I think this is required because arcs are drawn as Bezier curves with control points that contribute to the bounding box)
          clip (-1.2*radius,-1.2*radius) rectangle (1.2*radius,1.5*smallradius);

          %SHADING
          % Two shading paths to mimic the different light refraction of the front and the surface
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (180:0:waterradius and watersmallradius) -- cycle;
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (-180:0:waterradius and watersmallradius) -- cycle;

          %BIG CIRCLE
          % Due to the 'view' key, a circle with a fixed radius becomes an ellipse
          draw[thick,view=0,el,canvas is xy plane at z=0] (0,0) circle (radius);
          % No matter what the elevation of the view is, a (half-)sphere is always projected as a (half-)circle.
          draw[thick] (0,0) ++(0:radius) arc (0:-180:radius);
          %SMALL CIRLCE
          % Again using the 'view' key, the small circle can be drawn as two seperate arcs with fixed radius.
          draw[dashed,view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:180:waterradius);
          draw[view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:-180:waterradius);

          %triangle
          %draw[gray,dashed](0,0) -- (+2.84,-1.52);
          %draw[gray,dashed](0,0) -- (0,-1.52);
          %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
          %
          %node[below] at (0,-1.52) A;
          %node[right] at (2.84,-1.52) B;
          %
          %draw [thick,fill=black] (0,-1.52) circle (0.04);
          draw [thick,fill=black] (0,0) circle (0.04);
          %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
          node[above] at (0,0.2) O;
          %
          %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
          %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
          %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
          endtikzpicture

          enddocument





          share|improve this answer












          I know I'm quite late to the party, but I took this question as an opportunity to learn some more on the projection of spheres, and to re-use my answer here. I created a partially filled sphere, with a predetermined level waterlevel which should be between 0 and 1, which is projected with a certain elevation angle el which should be between 0 and 90. The best results are obtained with 0.2 < waterlevel < 1 and 10 < el < 40. In the following example el is set to 20 and the waterlevel to 0.5.



          enter image description here



          Of course, an animation can be made easily (with el still set to 20):



          enter image description here



          Disclaimer

          The projection of the hemisphere is correct, as is the projection of the water surface. The shading of the water is not completely correct. The 'front view', the part of the water that is touching the sphere, is an approximation, but that is invisible with waterlevel above approximately 0.35.



          MWE:



          documentclass[tikz,margin=2mm]standalone

          usetikzlibrary3d

          % small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
          makeatletter
          tikzoptioncanvas is xy plane at z%
          deftikz@plane@originpgfpointxyz00#1%
          deftikz@plane@xpgfpointxyz10#1%
          deftikz@plane@ypgfpointxyz01#1%
          tikz@canvas@is@plane

          % view=<azimuth>,<elevation> key https://tex.stackexchange.com/a/447401/74459
          tikzset
          view/.code args=#1,#2%
          % Set elevation and azimuth angles
          pgfmathsetmacroview@az#1
          pgfmathsetmacroview@el#2
          % Calculate projections of rotation matrix
          pgfmathsetmacroxvec@xcos(view@az)
          pgfmathsetmacroxvec@y-sin(view@az)*sin(view@el)
          pgfmathsetmacroyvec@xsin(view@az)
          pgfmathsetmacroyvec@ycos(view@az)*sin(view@el)
          pgfmathsetmacrozvec@x0
          pgfmathsetmacrozvec@ycos(view@el)
          % Set base vectors
          pgfsetxvecpgfpointxvec@x cmxvec@y cm
          pgfsetyvecpgfpointyvec@x cmyvec@y cm
          pgfsetzvecpgfpointzvec@x cmzvec@y cm
          ,

          makeatother

          begindocument

          begintikzpicture[scale=0.75,water shading/.style=ball color=cyan!50!white,fill opacity=0.5]

          % PRE-CALCULATIONS
          pgfmathsetmacroel20
          pgfmathsetmacroradius3.2
          pgfmathsetmacrosmallradiussin(el)*radius
          pgfmathsetmacrowaterlevel0.5 % between 0 and 1
          pgfmathsetmacrowaterradiussin(acos(-1+waterlevel))*radius
          pgfmathsetmacrowatersmallradiussin(el)*waterradius

          %SHADING
          % Two shading paths to mimic the different light refraction of the front and the surface
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (180:0:waterradius and watersmallradius) -- cycle;
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (-180:0:waterradius and watersmallradius) -- cycle;

          %BIG CIRCLE
          % Due to the 'view' key, a circle with a fixed radius becomes an ellipse
          draw[thick,view=0,el,canvas is xy plane at z=0] (0,0) circle (radius);
          % No matter what the elevation of the view is, a (half-)sphere is always projected as a (half-)circle.
          draw[thick] (0,0) ++(0:radius) arc (0:-180:radius);
          %SMALL CIRLCE
          % Again using the 'view' key, the small circle can be drawn as two seperate arcs with fixed radius.
          draw[dashed,view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:180:waterradius);
          draw[view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:-180:waterradius);

          %triangle
          %draw[gray,dashed](0,0) -- (+2.84,-1.52);
          %draw[gray,dashed](0,0) -- (0,-1.52);
          %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
          %
          %node[below] at (0,-1.52) A;
          %node[right] at (2.84,-1.52) B;
          %
          %draw [thick,fill=black] (0,-1.52) circle (0.04);
          draw [thick,fill=black] (0,0) circle (0.04);
          %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
          node[above] at (0,0.2) O;
          %
          %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
          %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
          %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
          endtikzpicture

          enddocument


          MWE animation:



          documentclass[tikz,margin=2mm]standalone

          usetikzlibrary3d

          % small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
          makeatletter
          tikzoptioncanvas is xy plane at z%
          deftikz@plane@originpgfpointxyz00#1%
          deftikz@plane@xpgfpointxyz10#1%
          deftikz@plane@ypgfpointxyz01#1%
          tikz@canvas@is@plane

          % view=<azimuth>,<elevation> key https://tex.stackexchange.com/a/447401/74459
          tikzset
          view/.code args=#1,#2%
          % Set elevation and azimuth angles
          pgfmathsetmacroview@az#1
          pgfmathsetmacroview@el#2
          % Calculate projections of rotation matrix
          pgfmathsetmacroxvec@xcos(view@az)
          pgfmathsetmacroxvec@y-sin(view@az)*sin(view@el)
          pgfmathsetmacroyvec@xsin(view@az)
          pgfmathsetmacroyvec@ycos(view@az)*sin(view@el)
          pgfmathsetmacrozvec@x0
          pgfmathsetmacrozvec@ycos(view@el)
          % Set base vectors
          pgfsetxvecpgfpointxvec@x cmxvec@y cm
          pgfsetyvecpgfpointyvec@x cmyvec@y cm
          pgfsetzvecpgfpointzvec@x cmzvec@y cm
          ,

          makeatother

          begindocument

          pgfmathsetmacroel20

          foreach fr [evaluate=fr as wl using fr/100] in 0,5,...,100
          begintikzpicture[scale=0.75,water shading/.style=ball color=cyan!50!white,fill opacity=0.5]

          % PRE-CALCULATIONS
          pgfmathsetmacroradius3.2
          pgfmathsetmacrosmallradiussin(el)*radius
          pgfmathsetmacrowaterlevelwl % between 0 and 1
          pgfmathsetmacrowaterradiussin(acos(-1+waterlevel))*radius
          pgfmathsetmacrowatersmallradiussin(el)*waterradius

          %CLIPPING
          % For the animation only (I think this is required because arcs are drawn as Bezier curves with control points that contribute to the bounding box)
          clip (-1.2*radius,-1.2*radius) rectangle (1.2*radius,1.5*smallradius);

          %SHADING
          % Two shading paths to mimic the different light refraction of the front and the surface
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (180:0:waterradius and watersmallradius) -- cycle;
          path[water shading] (-asin(1-waterlevel):radius)
          arc (-asin(1-waterlevel):-180+asin(1-waterlevel):radius)
          -- (-waterradius,-(1-waterlevel)*radius*cosel)
          arc (-180:0:waterradius and watersmallradius) -- cycle;

          %BIG CIRCLE
          % Due to the 'view' key, a circle with a fixed radius becomes an ellipse
          draw[thick,view=0,el,canvas is xy plane at z=0] (0,0) circle (radius);
          % No matter what the elevation of the view is, a (half-)sphere is always projected as a (half-)circle.
          draw[thick] (0,0) ++(0:radius) arc (0:-180:radius);
          %SMALL CIRLCE
          % Again using the 'view' key, the small circle can be drawn as two seperate arcs with fixed radius.
          draw[dashed,view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:180:waterradius);
          draw[view=0,el,canvas is xy plane at z=-(1-waterlevel)*radius]
          (0,0) ++(0:waterradius) arc (0:-180:waterradius);

          %triangle
          %draw[gray,dashed](0,0) -- (+2.84,-1.52);
          %draw[gray,dashed](0,0) -- (0,-1.52);
          %draw[gray,dashed](0,-1.52) --(+2.9,-1.52);
          %
          %node[below] at (0,-1.52) A;
          %node[right] at (2.84,-1.52) B;
          %
          %draw [thick,fill=black] (0,-1.52) circle (0.04);
          draw [thick,fill=black] (0,0) circle (0.04);
          %draw [thick,fill=black] (2.81,-1.52) circle (0.04);
          node[above] at (0,0.2) O;
          %
          %draw[gray,dashed] (0,-1.52) -- (3.8,-1.52);
          %draw[gray,dashed] (0,-3.22) -- (3.8,-3.22);
          %draw[thick,<->](3.4,-1.52) to node[fill=white] $3.5$ cm (3.4,-3.22);
          endtikzpicture

          enddocument






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          Max

          6,14311727




          6,14311727











          • This is beautiful. Thank you so much
            – Will Kim
            yesterday
















          • This is beautiful. Thank you so much
            – Will Kim
            yesterday















          This is beautiful. Thank you so much
          – Will Kim
          yesterday




          This is beautiful. Thank you so much
          – Will Kim
          yesterday

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f450223%2fwater-inside-a-hemispherical-bowl%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          Long meetings (6-7 hours a day): Being “babysat” by supervisor

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          Confectionery