1. defaultmatrix
Gets the default transformation matrix for the current device.
1.2. Stack Effects
| Level | Object |
|---|---|
0 |
|
| Level | Object |
|---|---|
0 |
|
1.3. Description
defaultmatrix replaces the value of matrix with the default transformation matrix for the current output device and pushes the modified matrix back on the operand stack.
The default matrix establishes the standard mapping from the default user coordinate system to device space for the current device. This matrix is device-dependent and defines the initial state before any transformations are applied.
For page-oriented devices, the default matrix is typically established by the page device setup. For display devices, it depends on the window system integration.
1.5. Examples
matrix defaultmatrix % Get device default matrix
% → e.g., [1 0 0 -1 0 792] for letter page
matrix currentmatrix % Get CTM
matrix defaultmatrix % Get default
% Compare the two matrices
matrix defaultmatrix setmatrix % Reset to default
% Equivalent to: initmatrix
1.6. Common Use Cases
1.6.1. Understanding Device Coordinate System
% Examine default transformation
matrix defaultmatrix
% For letter page, might be:
% [72 0 0 -72 0 792]
% Meaning: 72dpi, y-axis inverted, origin at top-left
1.7. Common Pitfalls
| Device-Dependent - The default matrix varies by device and is not portable. |
% These may differ on different devices:
matrix defaultmatrix % On printer: [72 0 0 -72 0 792]
matrix defaultmatrix % On display: [1 0 0 -1 0 1024]
| Not Always Identity - The default matrix is rarely the identity matrix. |
% Default matrix is usually NOT:
[1 0 0 1 0 0]
% It's typically something like:
[72 0 0 -72 0 792] % Letter page at 72dpi
Use initmatrix Instead - For resetting CTM, use initmatrix:
|
% Less clear:
matrix defaultmatrix setmatrix
% Clearer:
initmatrix
1.8. Error Conditions
| Error | Condition |
|---|---|
[ |
Array has fewer than 6 elements |
[ |
No operand on stack |
[ |
Operand is not an array |
1.9. Implementation Notes
-
The default matrix is established during device initialization
-
For page devices, it’s set by the
setpagedeviceoperator -
The matrix defines the initial coordinate system mapping
-
The default matrix typically includes:
-
Scaling to convert from points to device pixels
-
Possible y-axis inversion
-
Translation to position the origin
-
1.10. Typical Default Matrices
1.11. Matrix Components
For a typical page device:
[a b c d tx ty] = [72 0 0 -72 0 792]
-
a = 72: x-scale (points to device units) -
b = 0: no rotation -
c = 0: no shear -
d = -72: y-scale (negative = inverted) -
tx = 0: x origin -
ty = 792: y origin (page height in points)
1.12. Relationship to initmatrix
% These are equivalent:
initmatrix
matrix defaultmatrix setmatrix
% initmatrix is just a convenience
1.13. See Also
-
initmatrix- Reset CTM to default -
currentmatrix- Get current transformation -
setmatrix- Set transformation matrix -
matrix- Create identity matrix