CoursMecaniqueEnergie/Dessins/Marees/vectorField.tex

131 lines
3.3 KiB
TeX
Raw Normal View History

2016-12-02 09:35:58 +01:00
\documentclass[a4paper]{article}
\usepackage{pst-plot}
\pagestyle{empty}
\begin{document}
\SpecialCoor% importanmt for all examples
\begin{pspicture}(-6,-6)(6,6)
\psaxes{<->}(0,0)(-6,-6)(6,6)
\psset{arrows=->}
\multido{\ia=-5+1}{11}{%
\multido{\ib=-5+1}{11}{%
\pstVerb{/x \ia\space def
/y \ib\space def
y 0 eq
{/ValueTempA 0 def
/ValueTempB 0.5 def}
{/ValueTempZ 2 1 x x mul y y mul div add sqrt mul def
/ValueTempA 1 ValueTempZ div def
/ValueTempB x y ValueTempZ mul div def}
ifelse}
\psline(! x ValueTempA sub y ValueTempB sub)
(! x ValueTempA add y ValueTempB add)}}
\end{pspicture}
\begin{pspicture}(-6,-6)(6,6)
\psaxes{<->}(0,0)(-6,-6)(6,6)
\psset{arrows=->}
\multido{\ia=-5+1}{11}{%
\multido{\ib=-5+1}{11}{%
\pstVerb{/x \ia\space def
/y \ib\space def
y 0 eq
{/ValueTempA 0 def
/ValueTempB 0.5 def}
{/ValueTempZ 2 1 x x mul y y mul div add sqrt mul def
/ValueTempA 1 ValueTempZ div def
/ValueTempB x neg y ValueTempZ mul div def}
ifelse}
\psline(! x ValueTempA sub y ValueTempB sub)
(! x ValueTempA add y ValueTempB add)}}
\end{pspicture}
% From Michael Sharpe
\def\transl#1#2{%
#1\space 72 2.54 div mul #2\space 72 2.54 div mul translate 0 0 moveto}
\newif\ifnotbothz
\begin{pspicture}(-6,-6)(6,6)
\psaxes{<->}(0,0)(-6,-6)(6,6)
\multido{\n=-5+1}{11}{%
\multido{\N=-5+1}{11}{%
\notbothztrue
\ifnum\N=0
\ifnum\n=0
\notbothzfalse
\fi
\fi
\ifnotbothz
\psdot(0,0)
\pstverb{\transl{\n}{\N}\space
%next line gives a direction vector (y=\n,x=\N)
\n\space \N\space
atan rotate -9 0 moveto 18 0 rlineto stroke}
\fi}}
\end{pspicture}
\begin{pspicture}(-6,-6)(6,6)
\psaxes{<->}(0,0)(-6,-6)(6,6)
\multido{\n=-5+1}{11}{%
\multido{\N=-5+1}{11}{%
\notbothztrue
\ifnum\N=0
\ifnum\n=0
\notbothzfalse
\fi
\fi
\ifnotbothz
\psdot(0,0)
\pstverb{\transl{\n}{\N}\space
%next line gives a direction vector (y=-\n,x=\N)
\n\space neg \N\space
atan rotate -9 0 moveto 18 0 rlineto stroke}
\fi}}
\end{pspicture}
\clearpage
Another solution for a vector field:
\def\drawseg#1#2{%
\pscustom{%
\translate(#1,#2)
\rotate{(\dirseg{#1}{#2})} % Vector in direction of field at x=#1,y=#2
\psline(-.25,0)(.25,0)}}
\def\dirseg#1#2{-#2,#1} % Default direction field ($y'=-x/y$)
\begin{pspicture}(-6,-6)(6,6)
\psaxes{<->}(0,0)(-6,-6)(6,6)
\multido{\n=-5+1}{11}{%
\multido{\N=-5+1}{11}{%
\ifnum\N=0
\ifnum\n=0
\else
\drawseg{\n}{\N}
\fi
\else
\drawseg{\n}{\N}
\fi}}
\end{pspicture}
\def\dirseg#1#2{#2,#1} % Direction field example ($y'=x/y$)
\begin{pspicture}(-6,-6)(6,6)
\psaxes{<->}(0,0)(-6,-6)(6,6)
\psset{arrows=->}
\multido{\n=-5+1}{11}{%
\multido{\N=-5+1}{11}{%
\ifnum\N=0
\ifnum\n=0
\else
\drawseg{\n}{\N}
\fi
\else
\drawseg{\n}{\N}
\fi}}
\end{pspicture}
\end{document}