[pstricks] multiplication with multido variable / drawing a lattice
Brandon Kuczenski
brandon at 301south.net
Wed May 11 08:43:27 CEST 2011
On Mon, 9 May 2011, Christian Häger wrote:
> Hello,
>
> 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. I tried the calc package but couldn't make it work
> either.
>
You could always use fp.... although I suspect I'm a bit out of date.
I've never heard of \numexpr.
\usepackage[nomessages]{fp}
\FProot\sqrtthree{3}{2}
...
\multido{\nx=-6+1}{13}{
\multido{\ny=-7+1}{15}{
\FPmul\xvar\nx\sqrtthree
\FPmul\yvar\ny{2}
\FPmul\tmpvar\nx{1.4}
\FPadd\yvar\yvar\tmpvar
\psdot[dotsize=2.0pt](\xvar,\yvar)
}
}
More information about the PSTricks
mailing list