# What is the easiest way to automatically keep the fluid surface horizontal and the liquid's volume conserved when the container is rotated?

I have a symmetric container (a hollow object of revolution) that is partially filled with liquid. When we rotate the container about any axis perpendicular to our display, the surface of liquid must be parallel to the surface of liquid in a not-rotated container.

To be more realistic, the volume of liquid must be conserved. In other words, the area of the shaded region must be invariant under this rotation.

I want to make an animation by changing the rotation angle so automatic adjustment is a must.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-eucl}
\psset
{
PointName=none,
PointSymbol=none,
}

\def\containerpath
{%
\pstGeonode
(0,4){Top}
(0,0){Bottom}
(1,0){BottomRight}
(3,2){Right}
(1,3.5){NeckRight}
(1,4){TopRight}
\pstOrtSym{Top}{Bottom}{BottomRight,Right,NeckRight,TopRight}[BottomLeft,Left,NeckLeft,TopLeft]
\pscustom
{
\pscurve(BottomRight)(Right)(NeckRight)
\psline(TopRight)(TopLeft)(NeckLeft)
\pscurve(Left)(BottomLeft)
\closepath
}
}

\def\container
{%
\psset{unit=0.5cm}
\begin{pspicture}(-3,0)(3,4)
\psclip{\containerpath}
\psframe[linewidth=0,linestyle=none,fillstyle=solid,fillcolor=gray](-3,0)(3,2)
\endpsclip
\containerpath
\end{pspicture}
}

\begin{document}
\begin{pspicture}(6,2)
\rput(1.5,1){\container}
\rput{45}(5,1){\container}
\end{pspicture}
\end{document}


What is the easiest way to automatically keep the fluid surface horizontal and the volume of liquid conserved when the container is rotated? The top of the container is open so the angle of rotation must not make the liquid spilled out.

It is free for you to use either PSTricks or TikZ or others!

-
@Karl'sstudents: I would think you would need a function for the shape so that you can compute the vertical height to get the same area. –  Peter Grill Mar 19 '13 at 19:15
@Karl's students: you should indicate in the picture that the top is open then. –  g.kov Mar 19 '13 at 20:00
You mentioned preservation of "area" as a constraint. But if the body is a body of revolution, then conservation of area will not be the same as conservation of volume. –  Steven B. Segletes Mar 19 '13 at 22:30
@Karl'sstudents I see that this question remains unanswered. Giving it more thought leads me to think the best way to do this is, given the vagaries of the container geometry (as well as the challenges of volume integration for the conic section of an unusual body of revolution), to calculate offline the fluid location as a function of the tilt angle, and then, In LaTeX, use a look-up table to plot the liquid, based on the current value of vessel tilt. –  Steven B. Segletes Mar 27 '13 at 2:59
My thoughts: This is a mathematical question that belongs on math.sx, as you actually need to solve for the volume that is filled (and not the area). When you do have some mathematical solution for the height of the line, that height could easily be calculated and the area could easily be drawn with PSTricks or PGF. — Or do you actually only need the mathematical expression of the \pscurve? –  Qrrbrbirlbel Mar 28 '13 at 4:27
show 13 more comments

this might answer your question, although I'm afraid that this will not keep the volume conserved, because it will take much more math investigated to calculate the contained water. At least this will do the first job for you - keeping the surface parallel to the non-rotated container:

\documentclass[pstricks]{standalone}
\usepackage{pstricks,multido}

\def\Bottle#1{{\pscustom[linewidth=2pt]{%
\rotate{#1}
\psline(-1,3.5)(-1,4)(1,4)(1,3.5)
\pscurve(3,2)(1,0)\psline(-1,0)
\pscurve(-3,2)(-1,3.5)}}}

\def\BottleWithWater(#1)#2{%
\rput[c]{#2}(#1){%
\rput{*0}(0,0){%
\psclip{\Bottle{#2}}
\psframe*[linecolor=gray](-6,-2)(6,2)
\endpsclip}\rput{*0}(0,0){\Bottle{#2}}}}

\begin{document}

\multido{\iA=-45+5}{19}{%
\begin{pspicture}(-2.5,-0.5)(6,5.5)
\BottleWithWater(1.5,1){\iA}
\end{pspicture}}

\end{document}


Note: Don't know who is the original author, found it on PSTricks

Regards, Nick

-
The pink region will tell the history. –  Please don't touch Apr 2 '13 at 16:16