in reply to Translating python math to Perl

I see some familiar motifs. Since this all is about scribblings in 2D plane, to quote PDF (same with Postscript) Reference (relevant pages are very simple and concise, no math):

PDF represents coordinates in a two-dimensional space. The point (x, y) in such a space can be expressed in vector form as [ x y 1 ]. The constant third element of this vector (1) is needed so that the vector can be used with 3-by-3 matrices in the calculations described below.

The transformation between two coordinate systems is represented by a 3-by-3 transformation matrix written as follows:

| a b 0 |
| c d 0 |
| e f 1 |

Because a transformation matrix has only six elements that can be changed, it is usually specified in PDF as the six-element array [ a b c d e f ].

Coordinate transformations are expressed as matrix multiplications:

| a b 0 | [ x' y' 1 ] = [ x y 1 ] x | c d 0 | | e f 1 |

"e f" are to translate, "a d" to scale (let's omit rotation and skewing for simplicity). Suppose I want to translate by (32,64) and then scale by factor of 3:

pdl> p $m = pdl '3 0 0 ; 0 3 0 ; 32 64 1' [ [ 3 0 0] [ 0 3 0] [32 64 1] ]

And I have this dumb set of points:

pdl> p $points = rint transpose cat sequence(10),sequence(10)/3 [ [0 0] [1 0] [2 1] [3 1] [4 1] [5 2] [6 2] [7 2] [8 3] [9 3] ]

Then:

pdl> p $points->append(1) x $m [ [32 64 1] [35 64 1] [38 67 1] [41 67 1] [44 67 1] [47 70 1] [50 70 1] [53 70 1] [56 73 1] [59 73 1] ]

See? Coordinates were modified as requested.

"Six numbers per row/point" are six numbers (3 x,y pairs) required to append a cubic bezier curve segment to path -- this is another one which rings the bell, but maybe it's false alarm and I misread what they are trying to accomplish.