2

I am looking for explanation of how pstricks deals with measurement units. I am trying to write my custom postscript-only drawing commands, to be used within the \pspicture environment. For explanation why I need that, read at the end.

I need to start by writing a postscipt command that draws segments. However, when I draw a segment of length 72 postscript units, I do not get the same result as when drawing a 1-inch \psline. What is going on? How does pstricks measure units?

[Edit for clarification:] The first two commands are supposed to produce equal length lines but they don't. Why?

\documentclass{article}
\usepackage{auto-pst-pdf}
\usepackage{pst-plot}

\begin{document}
\psset{xunit=1cm, yunit=1cm}
\begin{pspicture}(0,0)(1,1)
\psline(0,0.1)(2.54,0.1)
\pstVerb{newpath 0 0 moveto 72 0 lineto stroke}
\pstVerb{newpath 0 -600 moveto 7200 -600 lineto stroke}
\pstVerb{newpath 0 -1400 moveto 8000 -1400 lineto stroke}
\end{pspicture}
\end{document}

I tried reading the source pstricks.tex but I find it unreadable.

I am trying to write a package that draws fancy things such as 3d vector field graphics, etc. Previously, for such purposes I've been using the \multido macro, and I've found it to be so poorly designed that I prefer doing everything in postscript directly.

I've used already available packages (for example, pst-3dplot) and I've found them to be very much wanting and completely unreliable. As a result I prefer to write everything myself.

To do more complicated things such as vector fields/surfaces, I need to be able to plot 2d segments correctly.

On a related note, what does the \pst@number\psyunit in the pstricks.tex file do/stand for? [Edit: to elaborate] The code:

\makeatletter
\pst@number \psxunit 
\makeatother

prints a numerical value of 28.45274. From the naming of the variable, I would expect that it measure the postscript units needed to draw 1cm, but those are 72/2.54 = 28.346456693. So, this variable must stand for something else. What?

  • In PostScript, 72 points are exactly one inch; it is what in TeX is called bp. – egreg Sep 02 '14 at 00:22
  • Then why does the code I have attached produce lines of different length? – Todor Milev Sep 02 '14 at 00:28
  • A TeX point (pt) is slightly smaller than a PostScript point (called a big point (bp) in TeX). 1in = 72bp = 72.27pt (see this question's answers or the TeXbook for full detail and explanation). So the number printed (28.45274) is 72.27/2.54, not 72/2.54. There is a slight discrepancy if you actually do the division, caused by TeX's well-known difficulties providing precise results for floating-point arithmetic. – Paul Gessler Sep 02 '14 at 01:54
  • Thanks for that explanation! Still, this does not explain why in the above example I need to move 8000 units to draw a line of pstricks length 2.54cm. – Todor Milev Sep 02 '14 at 02:48
  • The numbers in postscript commands are not points but scaled by the current postscript coordinate transformation matrix, pstricks has commands to let you access the current scaling factors, this appears to be a duplicate of the question linked in the "related" list. – David Carlisle Sep 02 '14 at 07:29

0 Answers0