3

I'm trying to create an image that shows (for example) the portion of a standard cylinder (\cos(v),\sin(v),u) that lies between the planes z=0 and z+y=5. Generating the cylinder itself is not an issue, but I would need to set the bounds for u from 0 to 5-\sin(v), which pstricks seems to hate; it gives me an Invalid argument error. Is there some simple way around this that I'm missing?

Edit: By request, what I'm trying right now thanks to Herbert. At this point I get no errors, but it gets hung up indefinitely in the compile:

\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}

\begin{document}
\begin{pspicture}(-10,-10)(10,15) 
\psset{
unit=1.0,
Decran=50,
viewpoint=15 55 35 rtp2xyz,
lightsrc=20 60 20 rtp2xyz,
ngrid=50 50,  
grid,  
resolution=720
}

\defFunction[algebraic]{cylinder}(u,v){cos(v)}{sin(v)}{u}

\psSolid[object=surfaceparametree,
base=0 2 pi pi neg,  
function=cylinder,
incolor=red!30,
fillcolor=red!30,
opacity=0.4,
plansepare={[0 0 1 -1]},
name=partiescylindre,
]

\axesIIID(0,0,0)(2,2,3)

\end{pspicture}
\end{document}
  • I remember a graphic very similar, that your case, in this page; but using tikz or pgfplots. But I don't remember the link nor tags. :( – juanuni Jun 22 '15 at 2:54
  • 1
    give an example what you already tried. – user2478 Jun 22 '15 at 5:53
  • @Herbert: I'm on a mobile right now, but as I said the cylinder draws just fine with u from 0 to 5 and v from pi to pi neg. But if I change the 5 to anything involving a v, I get an Invalid argument error. – Paul Jun 22 '15 at 6:03
  • your example dosn't hang, but it needs in fact of ngrid=50 50, a lot of time for the calculations. However, in the end there is a postscript error. I must have a look at it – user2478 Jun 24 '15 at 8:38
  • @Herbert: You're right, I changed it to ngrid=5 30 and it loads much faster. I must have just been impatient with my slow machine. I see the error now too; it goes away if I comment out the plansepare line. I've seen this error before when fooling around and using a plane that doesn't intersect the surface at all, but that shouldn't be the case this time. – Paul Jun 25 '15 at 0:56
3

Don't know if you are looking for something like this:

\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}

\begin{document}
\begin{pspicture}(-6,-5)(6,8)
    \psset{lightsrc=viewpoint,viewpoint=100 30 40 rtp2xyz,Decran=100}
    \psSolid[object=grille,base=-4 4 -4 4,ngrid=8](0,0,-1)
    \defFunction[algebraic]{G9}(t){1*cos(t)}{1*sin(t)}{1*sin(5*t)}
    \psSolid[object=cylindre,range=0 6.28,h=5,function=G9,axe=0 0 1,
             incolor=green!50,fillcolor=yellow!50,linewidth=0.01,ngrid=10 72](0,-3,0)
    \psSolid[object=cylindre,r=1,h=5,incolor=green!50,fillcolor=yellow!50,
             ngrid=5 36](0,3,0)
    \psSolid[object=plan,definition=equation,opacity=0.5,args={[0 1 1 -5] 180},
             planmarks,plangrid,base=-2 2 -2 2,showBase]
    \psSolid[object=cylindre,range=0 6.28,h=5,function=G9,axe=0 0 1,
             incolor=green!50,fillcolor=yellow!50,plansepare={[0 1 1 -5]},
             name=partiescylindre,
             linewidth=0.01,ngrid=10 72]
\end{pspicture}
\end{document}

enter image description here

  • YES, the plansepare command is exactly what I was looking for. I notice that you use a pre-defined cylinder function. do you know if it will work for general parametric surfaces? I included some code in an edit above; without the plansepare and name parameters it works just fine, but with them it seems to get hung up indefinitely. I get no errors, it just doesn't finish compiling. – Paul Jun 23 '15 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.