[pstricks] Re : Re : Elektrostatic Field

mluque5130 at aol.com mluque5130 at aol.com
Tue Jan 19 20:10:06 CET 2010


 
@Patrice  et all : Maybe it would be interesting to combine both methods? As in this example.
Nothing is perfect!
It is certainly necessary to code a routine directly to postscript. (Herbert ?) 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
\usepackage{pstricks,pst-func}
\SpecialCoor
\def\FieldLines{%
         /r1 xP xA sub dup mul yP dup mul add sqrt def
         /r2 xP xA add dup mul yP dup mul add sqrt def
        /V q1 r1 div
           q2 r2 div
           add def
%        Ex=-dV/dx
         /Ex q1 xP xA sub mul r1 3 exp div
             q2 xP xA add mul r2 3 exp div
             add def
%        Ey=-dV/dy
         /Ey yP
             q1 r1 3 exp div
             q2 r2 3 exp div
             add mul def
         /NormeE Ex dup mul Ey dup mul add sqrt def
         /dX Ex NormeE div pasX mul def
         /dY Ey NormeE div pasX mul def
}
\begin{document}
\begin{center}
\begin{pspicture*}(-6,-6)(6,6)
% les limites
\pstVerb{/xmin -5 def /xmax 5 def /ymin -5 def /ymax 5 def}%
% le pas d'itération
\pstVerb{/pasX 0.025 def}%
\pstVerb{/q1 1 def           % les charges
         /q2 1 q1 mul def
         /xA -2.2 def}%
% 15 degrés entre chaque ligne (24*15=360)
\multido{\iA=0+24}{15}{% 15 lignes de champ
\pstVerb{/xStart xA def
         /pasX q1 q1 abs div 0.05 mul def
         /xP xStart  pasX \iA\space cos mul add def
         /yP 0 pasX \iA\space sin mul add def}%
\parametricplot[plotpoints=2000,linecolor=blue]{xmin}{xmax}{%
        \FieldLines
        /xP xP dX add def
        /yP yP dY add  def
         xP yP
}
\pstVerb{/xStart xA neg def
         /pasX q2 q2 abs div 0.05 mul def
         /xP xStart pasX \iA\space cos mul add def
         /yP 0 pasX \iA\space sin mul add def}%
\parametricplot[plotpoints=2000,linecolor=blue]{xmin}{xmax}{%
        \FieldLines
        /xP xP dX add def
        /yP yP dY add  def
         xP yP
}}
\def\Potentiel{/r1 x xA sub dup mul y dup mul add sqrt def
               /r2 x xA add dup mul y dup mul add sqrt def
               /V q1 r1 div
                  q2 r2 div
                  add def
               V
                  }
\pstVerb{/y 0 def
          /Valeurs [
          -6 1 0 {/x exch def  \Potentiel } for
          ] def
          }%
\multido{\i=0+1}{7}{%
\psplotImp[linestyle=dotted,linecolor=red](-5,-5)(5,5){%
           \Potentiel Valeurs \i\space get sub}}%
\pscircle[fillstyle=solid](!xA 0){0.2}\pscircle[fillstyle=solid](!xA neg 0){0.2}
\end{pspicture*}
\end{center}
\end{document}

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

Best regards,

Manuel
 


 

 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20100119/b2d594ab/attachment.html>


More information about the PSTricks mailing list