1. Coordinate Transformations

Commands for coordinate system transformations and matrix operations.

1.1. Overview

The PostScript coordinate transformation system provides powerful tools for manipulating the coordinate space in which graphics are drawn. These commands fall into three main categories:

1.1.1. Basic Transformations

1.1.2. Matrix Operations

1.1.3. Coordinate Transformations

1.2. Transformation Matrix

PostScript uses a 6-element matrix to represent coordinate transformations:

[a b c d tx ty]

This matrix transforms coordinates according to:

x' = a×x + c×y + tx
y' = b×x + d×y + ty

Where:

  • a, d - Scaling factors in x and y

  • b, c - Rotation/skewing components

  • tx, ty - Translation components

The identity matrix is [1 0 0 1 0 0].

1.3. Current Transformation Matrix (CTM)

The CTM maps user space coordinates to device space coordinates. It is part of the graphics state and is affected by:

1.4. Common Operations

1.4.1. Centering Content

% Center a 100x100 square on page
306 396 translate  % Move to center of letter page
-50 -50 translate  % Move back by half size

1.4.2. Scaling and Rotation

% Scale by 2 and rotate 45 degrees
2 2 scale
45 rotate

1.4.3. Saving Transformations

gsave
  % Temporary transformations
  100 100 translate
  2 2 scale
  % Draw transformed content
grestore
% Original CTM restored

1.5. Status

Complete documentation for all transformation commands.