[pstricks] Re : Help Please: PSTricks code

Manuel Luque mluque5130 at aol.com
Fri Apr 1 10:54:30 CEST 2011


 Dear Boumediene,

Here's the code for two examples:

http://manuel.luque.perso.neuf.fr/dVcylinderSphere/

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass{article}
\usepackage{pst-solides3d}
\usepackage{pst-eucl}
\usepackage[latin1]{inputenc}
\usepackage[a4paper]{geometry}


% pour placer une flèche perpendiculaire
% en un point du globe
% défini par :
\def\NormalSphere(#1,#2,#3){%
% #1 rayon
% #2 longitude
% #3 latitude
\pstVerb{/latitude #3 def
         /longitude #2 def
         /Rayon #1 def
         /xP Rayon #2 cos #3 cos mul mul def
         /yP Rayon #2 sin #3 cos mul mul def
         /zP Rayon #3 sin mul def}%
\psSolid[object=vecteur,RotZ=#2,RotY=#3 neg,
         args=2 0 0](xP,yP,zP)}%
% pour repérer
% un point du globe
% défini par :
\def\psPointSphere(#1,#2,#3)#4{%
% #1 rayon
% #2 longitude
% #3 latitude
\pstVerb{%
         /xP #1 #2 cos #3 cos mul mul def
         /yP #1 #2 sin #3 cos mul mul def
         /zP #1 #3 sin mul def}%
\psPoint(xP,yP,zP){#4}}%\psdot(#4)

\date{\today }
\begin{document}

\section{Élément de volume cylindrique}
\begin{center}
\psset{lightsrc=100 -10 20 rtp2xyz,viewpoint=100 -10 20 rtp2xyz,Decran=100}
\begin{pspicture}(-8,-5)(6,10)
\psPoint(0,0,0){O}
\psPoint(5,0,0){X}
\psPoint(0,0,4){P01}
\psPoint(4 0.6 rd cos mul,4 0.6 rd sin mul,4){P11}
\psline(P01)(P11)
\psPoint(0,0,3){P02}
\psPoint(4 0.6 rd cos mul,4 0.6 rd sin mul,3){P12}
\psline(P02)(P12)
\psPoint(4 0.9 rd cos mul,4 0.9 rd sin mul,4){P21}
\psline(P01)(P21)
\psPoint(4 0.9 rd cos mul,4 0.9 rd sin mul,3){P22}
\psline(P02)(P22)
\pcline[arrows=|-|,offset=0.2,linecolor=red](P02)(P01)
\aput{:U}{d$h$}
\pcline[arrows=|-|,offset=0.2,linecolor=red](O)(P01)
\aput{:U}{$h$}
\pcline[arrows=|-|,offset=0.2,linecolor=red](P01)(P21)
\aput{:U}{$r$}
\psPoint(5 0.9 rd cos mul,5 0.9 rd sin mul,4){P23}
\pcline[arrows=|-|,offset=0.2,linecolor=red](P21)(P23)
\aput{:U}{d$r$}
\psSolid[
    object=cylindre,grid,opacity=0.5,
    h=6,r=4,%
%    hollow,
%    incolor=blue!30,
    fillcolor=yellow,
    ngrid=12 72](0,0,0)
\defFunction[algebraic]{F}(t)
   {5*cos(t)}{5*sin(t)}{}
\defFunction[algebraic]{G}(t)
   {4*cos(t)}{4*sin(t)}{}
\psSolid[object=grille,fillcolor=gray!20,
  base=-6 6 -6 6,action=draw]%
\psSolid[object=prisme,h=1,%grid,
   fillcolor=blue!30,
%   resolution=19,
   base=0.6 0.9 {F} CourbeR2+
        0.9 0.6 {G} CourbeR2+
      ](0,0,3)
\psSolid[object=prisme,h=0.01,%grid,
   fillcolor=red!30,
   base=0.6 0.9 {F} CourbeR2+
        0.9 0.6 {G} CourbeR2+
      ](0,0,0)
\psPoint(4 0.6 rd cos mul,4 0.6 rd sin mul,0){Pxy11}
\psPoint(4 0.9 rd cos mul,4 0.9 rd sin mul,0){Pxy12}
\psline(Pxy12)(O)(Pxy11)
\psPoint(5 0.6 rd cos mul,5 0.6 rd sin mul,0){Pxy31}
\psPoint(5 0.6 rd cos mul,5 0.6 rd sin mul,4){P31}
\psPoint(5 0.9 rd cos mul,5 0.9 rd sin mul,4){P32}
\psPoint(5 0.9 rd cos mul,5 0.9 rd sin mul,0){Pxy32}
\psline(Pxy31)(P31)
\psline(Pxy32)(P32)
\pstMarkAngle[MarkAngleRadius=1,LabelSep=1.2,arrows=->,arrowinset=0]{X}{O}{Pxy11}{$\phi$}
\pstMarkAngle[MarkAngleRadius=1.2,LabelSep=1.5,arrows=->,arrowinset=0]{Pxy11}{O}{Pxy12}{d$\phi$}
\axesIIID(0,0,6)(6,6,7)
\end{pspicture}
\end{center}
\section{Élément de volume sphérique}
\begin{center}
\psset{viewpoint=100 20 20 rtp2xyz,Decran=100,unit=1,lightsrc=viewpoint}%
\begin{pspicture}(-7,-2)(7,12)
\psSolid[
    object=grille,fillcolor=gray!20,
    base=-8 8 -8 8]%
\pstVerb{/radius1 8 def
         /radius2 6 def
         /Theta 40 def
         /Phi 50 def
         /dTheta 20 def
         /dPhi 20 def
         /CoorMxy21 {radius2 Theta cos mul Phi 0} def
         /CoorMxy22 {radius2 Theta cos mul Phi dPhi add 0} def
         /CoorMxy23 {radius2 Theta dTheta add cos mul Phi dPhi add 0} def
         /CoorMxy24 {radius2 Theta dTheta add cos mul Phi 0} def}%
\psPoint(0,0,0){O}
\psPoint(8,0,0){x}
\psPoint(0,8,0){y}
\psPoint(0,0,8){z}
\psPointSphere(radius1,Phi,Theta){M11}
\psPointSphere(radius1,Phi dPhi add,Theta){M12}
\psPointSphere(radius1,Phi dPhi add,Theta dTheta add){M13}
\psPointSphere(radius1,Phi,Theta dTheta add){M14}
\psPointSphere(radius2,Phi,Theta){M21}
\psPointSphere(radius2,Phi dPhi add,Theta){M22}
\psPointSphere(radius2,Phi dPhi add,Theta dTheta add){M23}
\psPointSphere(radius2,Phi,Theta dTheta add){M24}
\psline(O)(M21)
\psline(O)(M22)
\psline(O)(M23)
\psline(O)(M24)
\psPointSphere(radius2 Theta cos mul,Phi,0){Mxy21}
\psPointSphere(radius2 Theta cos mul,Phi dPhi add,0){Mxy22}
\psPointSphere(radius2 Theta dTheta add cos mul,Phi dPhi add,0){Mxy23}
\psPointSphere(radius2 Theta dTheta add cos mul,Phi,0){Mxy24}
\psSolid[object=trigospherique,linecolor=blue,linewidth=2\pslinewidth,
      definition=arcspherique,
      args=CoorMxy21 CoorMxy22]%
\psSolid[object=trigospherique,linecolor=blue,linewidth=2\pslinewidth,
      definition=arcspherique,
      args=CoorMxy23 CoorMxy24]%
\psline[linecolor=blue,linewidth=2\pslinewidth](Mxy21)(Mxy24)
\psline[linecolor=blue,linewidth=2\pslinewidth](Mxy22)(Mxy23)
\psline[linestyle=dashed,linewidth=0.5\pslinewidth](Mxy21)(M21)
\psline[linestyle=dashed,linewidth=0.5\pslinewidth](Mxy22)(M22)
\psline[linestyle=dashed,linewidth=0.5\pslinewidth](Mxy23)(M23)
\psline[linestyle=dashed,linewidth=0.5\pslinewidth](Mxy24)(M24)
\psline(O)(Mxy24)
\psline(O)(Mxy23)
\psSolid[
    object=calottesphere,
    fillcolor=yellow,
    hollow,
    linewidth=0.5\pslinewidth,
    incolor=blue!30,
    opacity=0.4,
    r=6,ngrid=18 72,grid,
    theta=90,phi=0]%
\pstVerb{ % coordonnées sphériques des différents points de la portion solide de sphère
         /S11 {[Phi 1 Phi dPhi add {/aPhi exch def radius1 aPhi Theta rtp2xyz} for]} def
         /S12 {[Theta 1 Theta dTheta add {/aTheta exch def radius1 Phi dPhi add aTheta rtp2xyz} for]} def
         /S13 {[Phi dPhi add -1 Phi{/aPhi exch def radius1 aPhi Theta dTheta add rtp2xyz} for]} def
         /S14 {[Theta dTheta add -1 Theta  {/aTheta exch def radius1 Phi aTheta rtp2xyz} for]} def
         /S21 {[Phi 1 Phi dPhi add {/aPhi exch def radius2 aPhi Theta rtp2xyz} for]} def
         /S22 {[Theta 1 Theta dTheta add {/aTheta exch def radius2 Phi dPhi add aTheta rtp2xyz} for]} def
         /S23 {[Phi dPhi add -1 Phi{/aPhi exch def radius2 aPhi Theta dTheta add rtp2xyz} for]} def
         /S24 {[Theta dTheta add -1 Theta  {/aTheta exch def radius2 Phi aTheta rtp2xyz} for]} def
         /M11 {radius1 Phi Theta rtp2xyz} def
         /M12 {radius1 Phi dPhi add Theta rtp2xyz} def
         /M13 {radius1 Phi dPhi add Theta dTheta add rtp2xyz} def
         /M14 {radius1 Phi Theta dTheta add rtp2xyz} def
         /M21 {radius2 Phi Theta rtp2xyz} def
         /M22 {radius2 Phi dPhi add Theta rtp2xyz} def
         /M23 {radius2 Phi dPhi add Theta dTheta add rtp2xyz} def
         /M24 {radius2 Phi Theta dTheta add rtp2xyz} def
         /L11 {S11 length 3 div cvi} def
         /L12 {S12 length 3 div cvi} def
         /L13 {S13 length 3 div cvi} def
         /L14 {S14 length 3 div cvi} def
         /L21 {S21 length 3 div cvi} def
         /L22 {S22 length 3 div cvi} def
         /L23 {S23 length 3 div cvi} def
         /L24 {S24 length 3 div cvi} def
         % longueur du contour 1
         /L1 {L11 L12 add L13 add L14 add} def
         % longueur du contour 2
         /L2 {L21 L22 add L23 add L24 add} def
         /posM11 {L1 L2 add} def
         /posM12 {L1 L2 add 1 add} def
         /posM13 {L1 L2 add 2 add} def
         /posM14 {L1 L2 add 3 add} def
         /posM21 {L1 L2 add 4 add} def
         /posM22 {L1 L2 add 5 add} def
         /posM23 {L1 L2 add 6 add} def
         /posM24 {L1 L2 add 7 add} def
         }%
\psSolid[object=new,linecolor=red,fillcolor=red!20,action=draw*,
        opacity=0.4,
        sommets= S11 aload pop % L11
                 S12 aload pop % L12 (origine = L11)
                 S13 aload pop % L13 (origine = L11 + L12)
                 S14 aload pop % L14 (origine = L13 + L12 +L11)
                 S21 aload pop % L21 (origine = L1)
                 S22 aload pop % L22 (origine = L1 +L21)
                 S23 aload pop % L23 (origine = L1 +L21 + L22)
                 S24 aload pop % L24 (origine = L1 +L21 + L22 +L23)
                 % les sommets
                 M11 M12 M13 M14 M21 M22 M23 M24,
        faces={[0 1 L1 1 sub{  } for] % face 0
               [posM21 L1 1 L2 L1 add 1 sub{  } for]% face 1
               [ posM21 posM11  % face 2
                L1 -1 L11 L12 add L13 add { } for
                posM14 posM24
                L1 L21 add L22 add L23 add 1 L1 L2 add 1 sub{ } for
                ]
               [posM11 posM21 L1 1 add 1 L1 L21 add {} for % face 3
                posM22 posM12
                L11 -1 0{} for]
               [posM13 posM23 L1 1 add L21 add L22 add -1 L1 L21 add {} for % face 4
                 L11 1 L11 L12 add {} for]
               [posM24 posM14 L11 L12 add L13 add -1 L11 L12 add {} for % face 5
                posM23 posM13 L11 L12 add 1 L11 L12 add L13 add { } for]
         }]
\pstMarkAngle[MarkAngleRadius=2,LabelSep=2.2,arrows=<-,arrowinset=0]{M24}{O}{z}{$\theta$}
\pstMarkAngle[MarkAngleRadius=1.8,LabelSep=2,arrows=<-,arrowinset=0]{M21}{O}{M24}{$d\theta$}
\pstMarkAngle[MarkAngleRadius=0.4,LabelSep=0.6,arrows=->,arrowinset=0]{x}{O}{Mxy21}{$\phi$}
\pstMarkAngle[MarkAngleRadius=0.8,LabelSep=1.1,arrows=->,arrowinset=0]{Mxy21}{O}{Mxy23}{d$\phi$}
\pcline[offset=-0.1,linestyle=none](O)(M14)
\aput{:U}{$r$}
\pcline[offset=-0.1,linestyle=none](M24)(M14)
\aput{:U}{\red d$r$}
\pcline[offset=-0.55,linestyle=none](O)(Mxy24)
\aput{:U}{$r\sin\theta$}
%\NormalSphere(radius1,Phi dPhi 2 div add,Theta dTheta 2 div add)
\axesIIID(6,6,6)(8,8,7)
\end{pspicture}
\end{center}
\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


 Best Regards.
 
ML


 

 

-----E-mail d'origine-----
De : Boumediene TOUIL <touildiden at yahoo.fr>
A : pstricks at tug.org
Cc : pstricks at tug.org
Envoyé le : Jeudi, 24 Mars 2011 16:03
Sujet : [pstricks] Help Please: PSTricks code


Dear Sir,
I am a PhD student in physics in Algeria, I'd like to type my articles and reports in LaTeX format with the PSTricks package.
Please, I'm a beginner, can you provide me the PSTricks code (.tex) of the surfaces and volumes element in cartesian, cylindrical (polar) and spherical coordinate systems attached in pdf file.
Thanking you in advance.
Best rega rds,
Boumediene    



      
 
_______________________________________________
PSTricks mailing list
PSTricks at tug.org
http://tug.org/mailman/listinfo/pstricks
archive: http://www.tug.org/pipermail/pstricks/

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20110401/75b5785a/attachment-0001.html>


More information about the PSTricks mailing list