..png)
Ich erstelle ein Bild mit pstricks und möchte Punkte darstellen, deren Koordinaten Brüche a/c, b/c sind, wobei a, b und c über bestimmte Bereiche verlaufen. Ich habe versucht, \numexpr zu verwenden, aber es rundet ab. Ich würde \dimexpr nicht verwenden, da ich davon ausgehe, dass eine Dimension (die mit pt oder so endet) als pstricks-Koordinate nicht willkommen ist. Ich habe versucht, pgf zu verwenden, aber ich bekomme die Syntax nicht zum Laufen:
\documentclass{article}
\usepackage{amsmath}
\usepackage{pstricks,pst-node,multido}
\RequirePackage{pgf}%
\begin{document}
\psset{xunit=5cm,yunit=5cm}
\begin{pspicture}(0,0)(1,1)
\multido{\iC=1+1}{5}{%
\multido{\iA=0+1}{\iC}{%
\multido{\iB=0+1}{\iC}{%
\pscircle*(\pgfmathparse{\iA/\iC},\pgfmathparse{\iB/\iC}){0.02}
}
}
}
\end{pspicture}
\end{document}
Gewünschte Ausgabe (erstellt mit TikZ, das für dieses 5x5-Beispiel funktioniert, aber bei den größeren Maßstäben, die ich verwenden möchte, den Speicher von TeX erschöpft).
Antwort1
\documentclass{article}
\usepackage{pstricks,multido}
\begin{document}
\psset{xunit=5cm,yunit=5cm}
\begin{pspicture}(0,0)(1,1)
\multido{\iC=1+1}{5}{%
\multido{\iA=0+1}{\iC}{%
\multido{\iB=0+1}{\iC}{%
\psdot(!\iA\space \iC\space div \iB\space \iC\space div)
}%
}%
}%
\end{pspicture}
\end{document}
oder
\documentclass{article}
\usepackage{pstricks,multido,pst-calculate}
\begin{document}
\psset{unit=8}
\begin{pspicture}(2,2)
\multido{\iC=1+1}{20}{%
\multido{\iA=0+1}{\numexpr\iC+1}{%
\multido{\iB=0+1}{\numexpr\iC+1}{%
\psdot[dotscale=0.5](\pscalculate{\iA/\iC},\pscalculate{\iB/\iC})
}%
}%
}%
\end{pspicture}
\end{document}
Antwort2
Sie haben vergessen aufzurufen \pgfmathresult
.
\documentclass{article}
\usepackage{amsmath}
\usepackage{pstricks,pst-node,multido}
\RequirePackage{pgf}%
\begin{document}
\psset{xunit=5cm,yunit=5cm}
\begin{pspicture}(0,0)(1,1)
\multido{\iC=1+1}{5}{%
\multido{\iA=0+1}{\iC}{%
\multido{\iB=0+1}{\iC}{%
\pgfmathparse{\iA/\iC}\xdef\myx{\pgfmathresult}
\pgfmathparse{\iB/\iC}\xdef\myy{\pgfmathresult}
\pscircle*(\myx,\myy){0.02}
}
}
}
\end{pspicture}
\end{document}
Nur aus Neugier, könnten Sie bitte auch Ihr Ti hinzufügenkZ-Beispiel? Ich bin etwas überrascht über den Fehler, den Sie erhalten.
AKTUALISIEREN: Ich habe keine Probleme, wenn ich das mit Ti machekZ, wo der Code kürzer ist, keine Pakete erforderlich sind und die Kompilierung bequemer ist (obwohl ich PSTricks wirklich mag).
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=10]
\foreach \iC in {1,...,15}{%
\foreach \iA in {0,...,\iC}{%
\foreach \iB in {0, ...,\iC}{%
\draw[fill=black] ({\iA/\iC},{\iB/\iC}) circle (0.002);
}
}
}
\end{tikzpicture}
\end{document}
Antwort3
Auch verfügbar inMetapost, hier eingewickelt in luamplib
so kompilieren mit lualatex
oder arbeiten Sie heraus, wie man es anpassen fürGMPoder einfaches MP.
Ich habe auch ein bisschen Farbe hinzugefügt.
\documentclass[border=5mm]{standalone}
\usepackage{luatex85, luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
n = 25;
for i = 1 upto n:
for j = 0 upto i:
for k = 0 upto i:
fill fullcircle
scaled 3
shifted ((j/i, k/i) scaled (n*cm))
withcolor 3/4(j/i, k/i, i/n);
endfor
endfor
endfor
endfig;
\end{mplibcode}
\end{document}