Quantcast
Channel: Are there examples written in PSTricks and they cannot be done using TikZ? - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 7

Answer by Dean Serenevy for Are there examples written in PSTricks and they cannot be done using TikZ?

$
0
0

By "popular demand", a forward Euler ODE solver. Very old code, so isn't really the most elegant, but gets the job done. Compile with latex or xelatex (no pdftex).

\documentclass{article}\usepackage{pstricks}\newcommand{\arrowedphaseplane}{     \pscustom{     \arrows{\PhasePlaneArrowsStyle}     \coor(\x@start,\y@start)(0,0)(1,1)     \code{20 dict begin %DEFINE NEW DICTIONARY           /as-arrows [\PhasePlaneArrows] def           /as-arrows-length as-arrows length def           /as-arrows-index 0 def  %ARROW ARRAY SETUP%           /as-y exch def /as-x exch def as-y sub neg /as-y-scale exch def                                         as-x sub neg /as-x-scale exch def           /as-x \x@start\space def /as-y \y@start\space def           moveto %setup that defines scaling for PS and moves to (x_0,y_0)%           1 1 \steps\space { %step control             as-arrows-index as-arrows length lt {               as-arrows as-arrows-index get eq {                 /as-arrows-index as-arrows-index 1 add def                 as-x as-x-scale mul                 as-y as-y-scale mul                 as-x \fx \space \dx \space mul add as-x-scale mul                 as-y \fy \space \dx \space mul add as-y-scale mul                 ArrowB pop pop pop pop                } if              } {pop} ifelse%             \fx \space \dx \space mul dup as-x-scale mul             \fy \space \dx \space mul dup 4 1 roll as-y-scale mul             rlineto %draw the line             as-x add /as-x exch def  %update x             as-y add /as-y exch def  %update y       } for }     }}\begin{document}\psset{xunit=1.3in,yunit=1.3in}\begin{pspicture*}(-1.5,-1.6)(1.6,1.5)  \psline[linewidth=1pt]{-}(-1.2,0)(1.2,0) % x-axis  \psline[linewidth=1pt]{-}(0,-1.2)(0,1.2) % y-axis  \psline[linewidth=0.5pt]{-}(1,-.05)(1,0.05)   % tick mark  \psline[linewidth=0.5pt]{-}(-1,-.05)(-1,0.05) % tick mark  \psline[linewidth=0.5pt]{-}(-.05,1)(0.05,1)   % tick mark  \psline[linewidth=0.5pt]{-}(-.05,-1)(0.05,-1) % tick mark  \pscircle*(0,0){2pt}  \rput[l](1.3,0){$x_j$}  \rput[l](0,1.3){$s_j$}  \rput[c](0,-1.4){$F(V_j)=0$}  \rput[l](1,-0.2){$1$}  \rput[l](0.2,1){$1$}  \psset{linewidth=1pt,arrowinset=1.4,arrowscale=2 1}  \def\PhasePlaneArrows{10 25}% iterations where arrows are to be drawn  \def\PhasePlaneArrowsStyle{->}  \def\dx{0.01}  \def\steps{1000}  \def\fx{as-x -0.2 div}                         % takes x'  \def\fy{as-x 1 as-y sub mul as-y 10 div sub}   % takes y'  \def\x@start{1}  \def\y@start{0.7}  \arrowedphaseplane  \def\x@start{-1}  \def\y@start{0.7}  \arrowedphaseplane  \def\x@start{1}  \def\y@start{-0.7}  \arrowedphaseplane  \def\x@start{-1}  \def\y@start{-0.5}  \arrowedphaseplane\end{pspicture*}\end{document}

enter image description here


Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>