[pstricks] multiplication with multido variable / drawing a lattice

Christoph Bersch usenet at bersch.net
Tue May 10 08:51:29 CEST 2011


Hi,

On 09.05.2011 17:32, Christian Häger wrote:
>
> I want to draw a 2-D lattice (regular array of points) with pstricks.
> The following example works fine for me
>
> \multido{\nx=-6+1}{13}{
> \multido{\ny=-7+1}{15}{
> \psdot[dotsize=2.0pt](\numexpr \nx*2,\numexpr \nx*1+\ny*2 )
> }
> }
>
> Unfortunately this is too restrictive and I need a way to multiply the
> \nx and \ny variables by real numbers, i.e I want to write something like
>
> \psdot[dotsize=2.0pt](\numexpr \nx*sqrt(3),\numexpr \nx*1.4+\ny*2 )
>
> but this doesn't work.

Use the \SpecialCoor and do the calculations in raw Postscript 
(indicated by the !)

\documentclass{article}
\usepackage{pstricks}
\usepackage{multido}
\begin{document}
\SpecialCoor
\psset{unit=0.2}
\begin{pspicture}[showgrid=true](-10,-25)(10,25)
\multido{\nx=-6+1}{13}{
   \multido{\ny=-7+1}{15}{
     \psdot[dotsize=2.0pt](!\nx\space 3 sqrt mul \nx\space 1.4 mul 
\ny\space 2 mul add)
   }
}
\end{pspicture}
\end{document}


Christoph


More information about the PSTricks mailing list