[pstricks] drawing implicit (polar) plot
Wim Neimeijer
w.neimeijer at hccnet.nl
Sun Jun 5 13:29:56 CEST 2005
I have a question concerning the implicit polar plot algorithm proposed
by Manfred Braun
and which is used as an example of http:/www.pstricks.de (polar2.tex)
In the postscript code where the streamlines and equipotential functions
are plotted
via a call to parametricplot, I am trying to figure out the mapping
between the complex function
$\Psi$ and the parameter $t$, excerpt of the code attached below.
Question : To be more specific, in the notes from polar2.tex it says,
solve the equation $f(z) = z + a^2/z$
using $z = x + i y$, which would give a quadratic equation ?
My maths gives me : $f(z) = \phi(x,y) + i \Psi(x,y) = $ where $Re f(z) =
( r + \frac{a^2}{r} ) \cos \phi $
and $Im f(z) = ( r - \frac{a^2}{r} ) \sin \phi$
Question : How does this lead to a quadratic equation under which
assumption ?
Question : How is the quadratic equation mapped to the variable $t$ in
the parametricplot ?
I want to understand the lines of code which I indented with HOW
to plot an other function to make the code a bit more generic.
If someone could help me, I greatly appreciated it.
Thanks in advance
Example taken from www.pstricks.de
=============== EXAMPLE ===============================
\listfiles
\documentclass[a4paper]{article}% Herbert Voss 2004-10-06
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{pstricks-add}
\usepackage{multido}
\usepackage{url}
%
% ----------- first example --------------------
%
\def\func{%
const0 x sin dup mul 3 mul div neg /p exch def
p abs sqrt neg /r exch def
const1 2.0 div neg /q exch def
p 0 lt {
p dup mul p mul q dup mul add 0 le {
q r 3 exp div arccos
3 div cos r dup add neg mul
}{
q r 3 exp div arch
3 div cosh r dup add neg mul
} ifelse
}{
q r 3 exp div arsh
3 div sinh r dup add neg mul
} ifelse
}
%
% ----------- second example --------------------
\def\compl{%
\pstVerb{
/cadd { 3 -1 roll add 3 1 roll add exch } def
/csub { exch 4 -1 roll sub neg 3 1 roll sub } def
/cmul { 3 index 2 index mul 3 index 2 index mul sub 5 1 roll
4 -1 roll mul 3 1 roll mul add } def
/crec { 2 copy dup mul exch dup mul add 3 -1 roll 1 index div
3 1 roll div neg } def
/creal { pop } def
/cimag { exch pop } def
/cabs { dup mul exch dup mul add sqrt } def
/carg { exch atan } def
/csqrt { 2 copy cabs sqrt 3 1 roll carg 2 div 2 copy cos mul 3 1
roll sin mul } def
}%
}
%
\newcommand\streamline[2]{%
% A streamline is drawn for #1 as the value of the stream function
% (divided by $2u_\infty$). The potential function, also normalized,
% takes values in the range (-1.5,+1.5). The (x, y)-coordinates of
% the points may be modified by providing PostScript commands in #2.
% The streamline through the stagnation points (#1 = 0) is excluded.
\parametricplot{-1.5}{1.5}{
HOW t #1 2 copy 2 copy cmul 1 0 csub csqrt cadd #2
}%
}
\newcommand\equipotline[2]{%
% An equipotential line is drawn in the same way. The potential must
% not assume the value 1 exactly, because of the singularity at the
% stagnation points.
% \parametricplot{0}{1.25}{
% #1 t 2 copy 2 copy cmul 1 0 csub csqrt cadd #2
% }%
\parametricplot{0}{1.25}{
HOW #1 t 2 copy 2 copy cmul 1 0 csub csqrt cadd #2
}%
}
\begin{document}
% This command provides PostScript commands for complex addition,
% subtraction, multiplication etc.
\psset{unit=2cm}
% \compl invokes the predefined complex arithmetics extensions
\begin{pspicture}(-3,-3)(3,3)%
\compl
\psset{linecolor=blue}
%\psline(-3,0)(-1,0) \pscircle(0,0){1} %\psline(1,0)(3,0)
%\multido{\n=0.125+0.125}{10}{
% \streamline{\n}{ }
% \streamline{\n}{ neg }
%}
\psset{linecolor=red}
\multido{\n=0+0.125}{8}{
\equipotline{\n}{ }
%\equipotline{\n}{ neg }
%\equipotline{\n}{ exch neg exch }
%\equipotline{\n}{ neg exch neg exch }
}
%\equipotline{0.9999}{ }
%\equipotline{0.9999}{ neg }
%\equipotline{0.9999}{ exch neg exch }
%\equipotline{0.9999}{ neg exch neg exch }
%\multido{\n=1.125+0.125}{4}{
% \equipotline{\n}{ }
% \equipotline{\n}{ neg }
% \equipotline{\n}{ exch neg exch }
% \equipotline{\n}{ neg exch neg exch }
%}
\end{pspicture}
\end{document}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20050605/2751f483/attachment.html
More information about the PSTricks
mailing list