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.


In reply to Re: Translating python math to Perl by Anonymous Monk
in thread Translating python math to Perl by cavac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.