# partially filled, tilted cylinder in TikZ [closed]

I have a diagram I'd like to reproduce in TikZ:

Picture a can (cylinder of radius r and height L) that has liquid in it. In each diagram, the can is tilted so that the surface of the liquid just touches where the top meets the sides. In the first diagram, the liquid covers the entire bottom, while in the second, only half.

Edit: Yes, I could do this myself given the time, but I'd like to see how others would handle the 3D aspect. Is there a better way to draw a projected circle than to draw an ellipse? [There you go @Andrew.]

The optimal code would use styles and named coordinates so that one could alter the diagram by changing only a few parameters.

-

## closed as too localized by Marco Daniel, Joseph Wright♦Oct 13 '11 at 15:55

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

–  Martin Scharrer Oct 12 '11 at 13:31
@MartinScharrer: Should be draw-this-for-me-im-busy. Possible additional tags: crowdsourcing, procrastination. :-) –  Matthew Leingang Oct 12 '11 at 13:38
Could close as "not a real question" given the distinct lack of question marks. –  Loop Space Oct 12 '11 at 14:02
Another possible tag: rep-cow. A question you can answer to "milk" a lot of rep points. –  Matthew Leingang Oct 12 '11 at 14:09
@MatthewLeingang: Tell you what, if you turn your question into a proper question then I'll turn my answer into a proper answer (assuming that no-one gets in first). –  Loop Space Oct 12 '11 at 20:49

Do you want something a bit like this?

If so, I'm afraid I don't know how to do that.

(Added in edit after question was closed. The above was produced using TikZ, contrary to my comment below. However, the code is messy and not elegant - it was a quick hack to make the joke. I've sent it privately to Matthew but I am not going to post it here. There are some interesting aspects in doing a drawing such as this one, so if anyone is interested in producing diagrams like this one then I encourage them to think carefully about which bits they could do and which would be hard, and then ask a focussed question specifically about the hard bits.)

-
+1 for the tease. –  Torbjørn T. Oct 12 '11 at 14:47
I guess Matthew wants it in grey and it should have a look as photo copied. (Or it's just my dirty display.) –  topskip Oct 12 '11 at 15:32
No +15 for you until I see your code. :-) –  Matthew Leingang Oct 12 '11 at 15:46
Wow, that's awesome Ansdrew. Can't recall ever laughing so much from something on this site. Now I know how to quickly post solutions here and build up a reputation. :-) –  Peter Grill Oct 12 '11 at 16:34
Code? What code? I don't have any code for that. I just took your diagram, added some colour using GIMP, and reposted it. Now, if you'd asked a sensible question like "How do you get proper 3D-looking circles in TikZ?" then maybe I could have provided some code to answer that. –  Loop Space Oct 12 '11 at 18:32

This example could be a good start for you, but it uses pst-solides3d (I found here...) and maybe you may get something similar with tikz.

\documentclass{minimal}
\usepackage{pst-solides3d}
\pagestyle{empty}
\SpecialCoor
\begin{document}
\begin{pspicture}(-5,-5)(7,9)
\psset{viewpoint=20 10 10,Decran=40,lightsrc=20 10 5,solidmemory}
\defFunction{cone}(u,v){u v Cos mul}{u v Sin mul}{u}
\psSolid[object=surfaceparametree,base=-2 2 0 2 pi mul,
inhue=0.8 0.2,hue=0.8 0.2,
function=cone,linewidth=0.5\pslinewidth,
ngrid=25 40,fillcolor=cyan!50,
intersectionplan={[1 0 0 -1]},
intersectioncolor=(bleu),
intersectionlinewidth=3,
intersectiontype=0,
name=XYZ,action=none]%
\psSolid[object=plan,definition=equation,
args={[1 0 0 0]},
%    args={[1 0 0 -1]},
fillcolor=blue!50,
base=-2 2 -2.5 2.5,ngrid=30 30,action=none,name=Plane]
\psSolid[object=fusion,base=XYZ Plane_s]
\gridIIID[Zmin=-2,Zmax=2](-2,2)(-2,2)
\end{pspicture}
\end{document}


-
–  Regis da Silva Oct 17 '11 at 3:01
Could you please add the code for that? –  moose Feb 4 '14 at 10:07