1

I'm willing to draw a contour around a cylinder. So far, I could get this one:enter image description here

The problem is that half of the circular part of the contour should be at the back of the cylinder which is not the case in what I drew.

In other words, I need to be able to see inside the cylinder, similar to this one for the torus case.

My current code is:

\documentclass[class=minimal,border=0pt]{standalone}
\usepackage{pstricks}
\definecolor{light}{rgb}{0.3,0.4,0.6}
\usepackage{pst-3dplot}
\pagestyle{empty}

\begin{document}
\def\radius{4 }\def\height {11}\def\thetaend {45}\def\thetaini {-305}
\begin{pspicture}(-3,-1.5)(-3,10)
\psset{viewpoint=30 0 15 rtp2xyz}
  \psCylinder[increment=5]{\radius}{\height}
\pstThreeDEllipse[beginAngle=\thetaini,
endAngle=\thetaend,
linecolor=green,linewidth=1.5pt,
opacity=0.5](0,0,1)(\radius,0,0)(0,\radius,0)
\pstThreeDLine[linecolor=green,linewidth=1.5pt,
opacity=0.5] (2.82,2.82,1)(2.82,2.82,10) 
\pstThreeDLine[linecolor=green,linewidth=1.5pt,
opacity=0.5] (2.29,3.27,1)(2.29,3.27,10)
\pstThreeDLine[linecolor=green,linewidth=1.5pt,
opacity=0.5] (2.29,3.27,10)(2.55,3.045,10.1)
\pstThreeDLine[linecolor=green,linewidth=1.5pt,
opacity=0.5] (2.82,2.82,10)(2.55,3.045,10.1)
\end{pspicture}
\end{document}

UPDATED NOTE:

recently, I've changed my code to this one

\documentclass[class=minimal,border=0pt]{standalone}

\usepackage{pstricks}
\definecolor{light}{rgb}{0.3,0.4,0.6}
\usepackage{pst-3dplot}
\usepackage{pst-solides3d}
\usepackage{fp}
\pagestyle{empty}

\def \planeLocRatio {1.0}      
\def \radius {0.4}
\def \height {0.6} 
\def \a {0.1}
\FPeval{\zcut}{height-a}
\def\thetaend {45}\def\thetaini {-305}
\def \planeLen {1}            
\FPeval{\imgsize}{planeLen+1} 

\begin{document}

    \begin{pspicture}[solidmemory](-\imgsize,-\imgsize)(\imgsize,\imgsize)

    % ==================  VIEW ===================
        \psset{
            viewpoint=10 45 20 rtp2xyz,
            lightsrc=viewpoint,
            %lightintensity=1.25
            }
    %===================Elliptical arc=======================
    \pstThreeDEllipse[
          beginAngle=\thetaini,
          endAngle=\thetaend,
          linecolor=black,
          linewidth=1.5pt,
          args=0 2 \a 45, 
          opacity=0.5
          ](0,0,\a)(0,2,0)(2,0,0) % can't understand why "2" and not \radius!

    %===================Cylinder=================

    \psSolid[
        object=cylindre,
          name=myCylinder,
          incolor=yellow,
          fillcolor=red,
          h=\height,
          ngrid=90 50,
          grid=false,
          hue=0.3 1,
          r=\radius,
          opacity=0.3,
          hollow=true,
%         intersectiontype=0,
%             intersectionplan=0 0 0 \a,
%         intersectioncolor=(black),
          action=draw**,
          ](0,0,0)

    %=======================Lines=============================
    \pstThreeDLine[
          linecolor=black,
          linewidth=1.5pt,
          opacity=0.5
          ] (0.282,0.282,\a)(0.282,0.282,0.5) %rcos(45), rsin(45)
    \pstThreeDLine[
          linecolor=black,
          linewidth=1.5pt,
          opacity=0.5
          ] (0.229,0.327,\a)(0.229,0.327,0.5)
    \pstThreeDLine[
          linecolor=black,
          linewidth=1.5pt,
          opacity=0.5
          ] (0.229,0.327,0.5)(0.255,0.3045,0.51)
    \pstThreeDLine[
          linecolor=black,
          linewidth=1.5pt,
          opacity=0.5
          ] (0.282,0.282,0.5)(0.255,0.3045,0.51)

    \end{pspicture}

\end{document}

with the outcome which it's elliptical arc is wrong. enter image description here

Removing the "Elliptical arc" section and drawing the intersection plane has better result, but i can not an arc of this circle. enter image description here.

Thus, the remained problem is either I need to draw an intersection arc(which I couldn't find any way), or I need to find the error in the "Elliptical arc" part of the code.

Does anyone have a suggestion?

1

2 Answers 2

2

enter image description here

\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}
\begin{center}
\begin{pspicture}(-5,-3)(5,5)
\psframe(-5,-3)(5,5)
\pstVerb{/hauteur 5 def /rayon 2 def /angleT 80 def 
/pointVue {20 angleT 30 rtp2xyz}   def
/jaunepale {0 0 0.25 0 setcmykcolor} def}%
\psset{viewpoint=pointVue,Decran=15,lightsrc=50 60 27 rtp2xyz,solidmemory}
\psSolid[object=grille,base=-4 4 -4 4]%
\psSolid[object=cylindre,
        h=hauteur,r=rayon,grid,linewidth=0.001,
        hue=0 1,fcol=0 (jaunepale),opacity=0.6,
        ngrid=1 60](0,0,0)
\psSolid[object=plan,definition=normalpoint,args={0 0 hauteur [0 0 1]},
         action=none,
         base=-4 4 -4 4,
         name=monplanH]
\psset{plan=monplanH}
\psProjection[object=cercle,linewidth=0.05,
              args=0 0 rayon]
\psSolid[object=plan,definition=normalpoint,args={0 0 0 [0 0 1]},
         action=none,
         base=-4 4 -4 4,
         name=monplanB]
\psset{plan=monplanB}
\psProjection[object=cercle,linewidth=0.05,
              args=0 0 rayon,range=-90 angleT add 90 angleT add]
\psProjection[object=cercle,linewidth=0.05,linestyle=dashed,
              args=0 0 rayon,range=90 angleT add 270 angleT add ]
\psPoint(angleT sin rayon mul,angleT cos rayon mul neg,0){A}
\psPoint(angleT sin rayon mul,angleT cos rayon mul neg,hauteur){B}
\psline[linewidth=0.05](A)(B)
\psPoint(angleT sin rayon mul neg,angleT cos rayon mul,0){C}
\psPoint(angleT sin rayon mul neg,angleT cos rayon mul,hauteur){D}
\psline[linewidth=0.05](C)(D)
\pstVerb{/epsilon 10 def
         /epsilon1 90 epsilon sub def
         /epsilon2 90 epsilon add def
         /xe1 rayon epsilon1 cos mul def
         /ye1 rayon epsilon1 sin mul def
         /ze1 0.5 def
         /xe2 rayon epsilon2 cos mul def
         /ye2 rayon epsilon2 sin mul def
         /ze2 0.5 def
         /Ht 3 def}%
\psPoint(xe1,ye1,ze1){M1}%\psdot(M1)
\psPoint(xe2,ye2,ze2){M2}%\psdot(M2)
\psPoint(xe1,ye1,Ht){H1}%\psdot(H1)
\psPoint(xe2,ye2,Ht){H2}%\psdot(H2)
\psline[linecolor=red](M1)(H1)\psline[linecolor=red](M2)(H2)
\psSolid[object=plan,definition=normalpoint,args={0 0 ze1 [0 0 1]},
         action=none,
         base=-4 4 -4 4,
         name=monplanC]
\psset{plan=monplanC}
\psProjection[object=cercle,linewidth=0.05,linecolor=red,
              args=0 0 rayon,range=-90 angleT add epsilon1]
\psProjection[object=cercle,linewidth=0.05,linecolor=red,
              args=0 0 rayon,range=epsilon2 90 angleT add]
\psProjection[object=cercle,linewidth=0.05,linestyle=dotted,linecolor=red,
              args=0 0 rayon,range=90 angleT add 270 angleT add]
\psSolid[object=plan,definition=normalpoint,args={0 0 Ht [0 0 1]},
         action=none,
         base=-4 4 -4 4,
         name=monplanC]
\psset{plan=monplanC}
\psProjection[object=cercle,linewidth=0.05,linecolor=red,
              args=0 0 rayon,range=epsilon1 epsilon2]
\end{pspicture}
\end{center}
\end{document} 
1
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. A suggestion: Do us a favour and change your username to something more telling than "user1234". Commented Feb 28, 2015 at 13:27
0

enter image description here

\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}
\begin{center}
\begin{pspicture}(-5,-5)(5,5)
\pstVerb{/hauteur 5 def /rayon 2 def /angleT 20 def}%
\psset{viewpoint=20 angleT 30 rtp2xyz,Decran=20,lightsrc=20 30 27 rtp2xyz,solidmemory}
\psSolid[object=grille,base=-5 5 -5 5]%
\psSolid[object=cylindre,
        h=hauteur,r=rayon,grid,
        fillcolor=cyan!20,
        ngrid=1 60](0,0,0)
\psSolid[object=plan,definition=normalpoint,args={0 0 hauteur [0 0 1]},
         action=none,
         base=-4 4 -4 4,
         name=monplanH]
\psset{plan=monplanH}
\psProjection[object=cercle,linewidth=0.05,
              args=0 0 rayon]
\psSolid[object=plan,definition=normalpoint,args={0 0 0 [0 0 1]},
         action=none,
         base=-4 4 -4 4,
         name=monplanB]
\psset{plan=monplanB}
\psProjection[object=cercle,linewidth=0.05,
              args=0 0 rayon,range=-90 angleT add 90 angleT add]
\psPoint(angleT sin rayon mul,angleT cos rayon mul neg,0){A}
\psPoint(angleT sin rayon mul,angleT cos rayon mul neg,hauteur){B}
\psline[linewidth=0.05](A)(B)
\psPoint(angleT sin rayon mul neg,angleT cos rayon mul,0){C}
\psPoint(angleT sin rayon mul neg,angleT cos rayon mul,hauteur){D}
\psline[linewidth=0.05](C)(D)
\end{pspicture}
\end{center}
\end{document} 
2
  • Hmmm, this doesn't seem to answer the question...
    – Werner
    Commented Feb 26, 2015 at 7:19
  • Thanks, but It is not what I'm looking for.
    – Shasa
    Commented Feb 26, 2015 at 15:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .