Search code examples
postscript

Postscript: discover rotate/scale value


How can I discover the values of rotate/scale? For example, after I issue the following command:

90 rotate

the current rotation is set to 90. How do I discover what rotate is set to?


Solution

  • Rotation (also scaling and shearing) do not have individual values. All such transformations are rolled up into the Current Transformation Matrix (CTM).

    You can find an excellent description of the CTM and the transformations in the PostScript Language Reference Manual, especially sections 4.3.1 to 4.3.3. Its an important area to understand for PostScript as the CTM underpins all drawing operations. Its really too complex to explain in this forum I think.

    The short answer is that there is no simple solution, you have to do some matrix algebra to find out where points map to. A common trick is to pass the co-ordinates of the unit square through the CTM (points 0,0 and 1,1) and see where the transformed points end up.