画出圆柱体的轮廓

画出圆柱体的轮廓

我想画一个圆柱体的轮廓。到目前为止,我可以得到这个:在此处输入图片描述

问题是轮廓的圆形部分的一半应该位于圆柱体的后部,而我所画的并非如此。

换句话说,我需要能够看到圆柱体内部,类似于这个对于环面的情况。

我当前的代码是:

\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}

更新说明:

最近,我把代码改成了这个

\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}

结果是它的椭圆弧是错误的。 在此处输入图片描述

去掉“椭圆弧”部分,画出相交平面会有更好的效果,但是我画不出这个圆的圆弧 在此处输入图片描述。。

因此,剩下的问题要么是我需要绘制一个相交圆弧(我无论如何都找不到),要么是我需要在代码的“椭圆弧”部分找到错误。

有人有建议吗?

答案1

在此处输入图片描述

\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} 

答案2

在此处输入图片描述

\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} 

相关内容