# 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.

• Oct 12, 2011 at 13:31
• @MartinScharrer: Should be draw-this-for-me-im-busy. Possible additional tags: crowdsourcing, procrastination. :-) Oct 12, 2011 at 13:38
• Could close as "not a real question" given the distinct lack of question marks. Oct 12, 2011 at 14:02
• Another possible tag: rep-cow. A question you can answer to "milk" a lot of rep points. Oct 12, 2011 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). Oct 12, 2011 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.)

• I guess Matthew wants it in grey and it should have a look as photo copied. (Or it's just my dirty display.) Oct 12, 2011 at 15:32
• No +15 for you until I see your code. :-) Oct 12, 2011 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. :-) Oct 12, 2011 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. Oct 12, 2011 at 18:32
• I'm also waiting for the codes Oct 12, 2011 at 19:45

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}


• Oct 17, 2011 at 3:01
• Could you please add the code for that? Feb 4, 2014 at 10:07