[pstricks] PSTricks test numérique

Herbert Voss herbert49 at googlemail.com
Mon Jun 18 18:18:08 CEST 2007


mathsattacks at free.fr wrote:
> Bonjour à tous.
> 
> Je voudrais savoir, s'il est possibe avec PSTricks de faire quelque
> chose du genre :
> (je fais du langage formel juste pour la compréhension et rendre la
> chose intelligible)
> 
> \begin{pspicture}(-5,5)(-5,5)
> "for k from -5 to 5 step 0.5 do
>     for n from -5 to 5 step 0.5 do
>          if n^2+3<n*k^2 then faire \psdots(k,n) fi
>    od
> od"
> \end{pspicture}
> 
> Bien sûr, je sais que les boucles "for" se font très bien avec la
> commande \multido, ce n'est pas l'objet de ma question (j'ai mis des
> for... juste pour qu'on voit en un coup d'oeil). Par contre, l'objet
> de ma question se porte sur la ligne :
> "if n^2+3<n*k^2 then faire \psdots(k,n) fi" (et là je sèche)
> Comment faire proprement ce genre de test numérique sous PSTricks ?


\documentclass{article}
\usepackage{pstricks,multido}

\makeatletter
\def\psDot{\pst at object{psDot}}% a modified \psdot
\def\psDot at i(#1,#2){%
  \begin at SpecialObj%
  \pst@@getcoor{#1,#2}%
  \addto at pscode{
    #2 dup mul 3 add  % n^2+3
    #2 #1 dup mul mul % n*k^2
    lt {
      \psk at dotsize
      \@nameuse{psds@\psk at dotstyle}%
      \pst at coor Dot } if }%
  \end at SpecialObj}
\makeatother

\begin{document}

\begin{pspicture}(-5,5)(-5,5)
  \multido{\rk=-5.0+0.5}{21}{%
    \multido{\rn=-5.0+0.5}{21}{\psDot[linecolor=red](\rk,\rn)}}
\end{pspicture}

\end{document}

Herbert


-- 
http://PSTricks.tug.org
http://tug.org/CTAN/info/math/voss/



More information about the PSTricks mailing list