## Coordinate Spaces & Transformations in InDesign — Chap.1-3

October 18, 2015 | Tips | en

Dealing with coordinate spaces and transformation matrices is one of the most obscure and underappreciated exercises in InDesign scripting and programming. The fault mainly lies with Adobe documentation, especially the Scripting DOM reference, which does not clearly explain the topic and some of its essential keys. The following document (PDF, Chapters 1-3) attempts to shed some light on the beast…

• Next chapter now available: “Coordinate Spaces & Transformations in InDesign — Chapter 4”

## Comments

A much needed guide to this tricky topic. Thanks very mucch, Marc.

Peter

Hi Marc,

Very interesting text, thanks very much. One comment and one question: you write that an affine map is an array of six numbers, but you don't really point out what those numbers are. Later on in the text we get an idea, but a plain statement would be helpful.

Could you summarise what the six numbers are?

Thanks, and looking forward to chapter 2,

Peter

Hi Peter,

Thanks for your feedback.

> You write that an affine map is an array of six numbers,

> but you don't really point out what those numbers are.

Well, those numbers are nothing but 'parameters' (in French we say 'coefficients') of the affine function. Their individual meaning—if you really want to understand what they 'mean'—is not easy to illustrate in the general case, although it becomes obvious in pure canonical transformations (scaling, rotation, translation).

But let's try to clarify:

• First, at the abstract level, an AFFINE MAP is by definition a function between two affine spaces — cf. http://en.wikipedia.org/wiki/Affine... — that *operates linearly on the vectors*. In R, it simply has the generic form:

x -> ax + b

where a and b are the constant parameters we are talking about.

• Now, in the GEOMETRIC PLANE, viz R×R, an affine map has the form:

(x,y) -> (ax+cy+e, bx+dy+f)

where a,b,c,d,e,f are our esoteric numbers! As above, they act as the parameters of the function, which then reflects a geometric transformation that always preserves collinearity. The most sensible property of affine transformations is that they take parallelograms to parallelograms. And, given two parallelograms P1 and P2, there is always an affine map that takes P1 to P2. In other words you can find a set of parameters (a,b,c,d,e,f) so that the function above takes P1 to P2.

• So, what do (a,b,c,d,e,f) 'mean' for ordinary mortals? I just can say that they DEFINE a function. However, the class of possible affine maps contains very basic transformations that we easily visualize. For instance, if a=d=1 and c=b=0 you get a simple TRANSLATION:

(x,y) -> (x+e, y+f)

Here you see that (e,f) is the translation vector. Also, if c=e=b=f=0 you get the map

(x,y) -> (ax, dy)

which obviously is a SCALING transformation.

In the very general case, an affine map is a compound of those basic transformations that I refer to as 'canonical' (see the section Matrix Patterns in my PDF.) So you cannot conclude e.g. that 'a' is in itself a scaling factor, because 'a' may also contribute at some level to a ROTATION angle (the cosinus in the ROTATION pattern).

• Why are our six numbers shown in a 3×3 matrix, as follows,

a b 0

c d 0

e f 1

that's purely conventional, and practical. Using this presentation allows to define a PRODUCT operation and other things that make it easy to compound or reverse affine transformations by numeric calculations.

I hope these details allow you to see more clearly.

@+

Marc

Beautiful layout and wonderfully helpful!

Thanks for sharing!

@ Justin

Thanks a lot for your support.

I hope this work will help my colleagues to some extent.

Always happy to have feedback :)

Best,

Marc