12 Replies Latest reply on Mar 15, 2012 12:09 AM by Alfred Angkasa

# [rotation at idml]

hello..

i make a design using indesign cs5. after that i change the file into a .zip file and i extract it.

all of the element appear in spread folder. and all of it have a itemtransfrom that refer to the location and angle.

i already know how to count the location for each element, but how do i know the angle? how can i count it? because i need to convert itu from idml file in to the other file.

i using .NET.

for example i have a rect with itemtransform="1 0 0 1 0 0". that itemtransform angle is 0. because when i design, i'm not rotate it. but in code, how can i count it that the angle is 0??

is there any possible to know the angle?

lets say if rotate to 45 degrees, the itemtransform will look like

ItemTransform="0.7071067811865476 -0.7071067811865476 0.7071067811865476 0.70710678118  65476 391.5768445275186 267.61677463457306". but how do i know that the itemtransform refer to 45 degree??

your answer will be a big help for me to done this project.. thanks. i'm waiting for your answer.

• ###### 1. Re: [rotation at idml]

You need to read the IDML Specification.

This is a bit tricky, though, because you are asking how you find the rotation angle in an affine transformation. What if there is not only rotation but also other transformations? Given an IDML transformation matrix of the form [a b c d e f ], then:

If there is only rotation, then a rotation by angle theta is given as [ cos(theta) sin(theta) -sin(theta) cos(theta) 0 0 ] and if there is only translation then it is [ 1 0 0 1 x y ]. So in your case since a=-b=c=d, that's a very special case since that only happens at theta=45 degrees. That is cos(45)=sin(45)=-sin(45).

The more general case is if a=d and arccos(a)=arcsin(b)=-arcsine(c) then you have a pure rotation by arccos(a) degrees (or arcsin(b) if you prefer).

If you have more complicated transformations (i.e. scaling or shearing in addition to rotation), then you'll need more math than I am able to easily summon right now.

Edit: Oops, I wrote 90 degrees where I meant 45 degrees. Sorry.

• ###### 2. Re: [rotation at idml]

Hi John,

thanks for your answer. how do i calculate it John?

let's say if i also want to have the scaling, skewing, and translation. how could i calculate?

can you give me an example?

thanks.

• ###### 3. Re: [rotation at idml]

Look up Transformation Matrix. Scaling, skewing, and translation are exactly the three members (in pairs of x,y) of a matrix, as John already told you.

• ###### 4. Re: [rotation at idml]

Jongware wrote:

Look up Transformation Matrix. Scaling, skewing, and translation are exactly the three members (in pairs of x,y) of a matrix, as John already told you.

Unfortunately this is not helpful. Because if you have these operations going on at the same time, it's necessary to decompose the matrix into the product of the scaling matrix, the skewing matrix, the translation matrix, and the rotation matrix. And that is not explained by the IDML spec.

Alfred:

thanks for your answer. how do i calculate it John?

I'm sorry, I thought I was clear. After verifying that it is solely a rotation, you take the arc cosine of the first number (or the arc sine of the second number).

The arcsine of .707 is 45 degrees.

let's say if i also want to have the scaling, skewing, and translation. how could i calculate?

I think you probably need to go take a class in linear algebra, matrices, and computer graphics and come back.

I asked some colleagues who understand this stuff this question last night and after 2 and a half hours and several edits to Wikipedia, they came back with a closed-form expression for the rotation. Unfortunately their answer seems to be wrong.

Maybe you should tell us why you thnk you need this.

• ###### 5. Re: [rotation at idml]

Uh, wait. Isn't this thekind of math problem where there may be more than one possible answer?

• ###### 6. Re: [rotation at idml]

They gave me a different answer this morning, but that one was wrong too [sigh], btw.

[Jongware] wrote:

Uh, wait. Isn't this thekind of math problem where there may be more than one possible answer?

Well, yes and no. I think there are multiple answers, but there is an easy rule to choose between them, or there is a "canonical representation" or "normal form."

This is not solely because: "Transformations are applied in the following order: scale, shear, rotate, translate."

• ###### 7. Re: [rotation at idml]

Hmm. Well, I think one of the simpler answers you'll get is for an IDML transform of [a b c d e f], you can expect the rotation angle to be given by the arctangent((c-b)/(a+d)).

That's about 5 times simpler than the expresison I tried before.

But in the presence of skew (shear) some of the skew will make it into the rotation, and that might not give you waht you want.

• ###### 8. Re: [rotation at idml]

Hi John & [Jongware], sorry for the late reply..

i need that to calculate the angle. but now i just tried to get the first matrix (m11) to calculate the angle.

and now, how about the center point?

i have a spread. inside a spread, i have 3 pages. can i know where is the center point? is it (0,0) in the middle? i mean by calculate the total width of the page and divide by pages count, total height divide by pages count.. is that true?? or still false?? thanks.

• ###### 9. Re: [rotation at idml]

i need that to calculate the angle. but now i just tried to get the first matrix (m11) to calculate the angle.

I'm sorry, I do not understand the question.

and now, how about the center point?

IDML does not deal with the center point, only the boundary corners. You will have to determine the center point yourself. This may be difficult for non-polygons.

i have a spread. inside a spread, i have 3 pages. can i know where is the center point? is it (0,0) in the middle? i mean by calculate the total width of the page and divide by pages count, total height divide by pages count.. is that true?? or still false?? thanks.

I don't know offhand. This is trivial to test. So test it!!

The IDML spec reads:

The origin of the spread coordinate system is located at center of the spread. The left edge of the

first right hand page in the spread aligns with the horizontal center of the spread; the right edge of

the first left hand page in the spread appears to the left. The vertical centers of the pages align with

the vertical center of the spread. Each spread has its own coordinate system origin.

Did you read it before posting?

• ###### 10. Re: [rotation at idml]

John Hawkinson wrote:

i need that to calculate the angle. but now i just tried to get the first matrix (m11) to calculate the angle.

I'm sorry, I do not understand the question.

and now, how about the center point?

IDML does not deal with the center point, only the boundary corners. You will have to determine the center point yourself. This may be difficult for non-polygons.

i have a spread. inside a spread, i have 3 pages. can i know where is the center point? is it (0,0) in the middle? i mean by calculate the total width of the page and divide by pages count, total height divide by pages count.. is that true?? or still false?? thanks.

I don't know offhand. This is trivial to test. So test it!!

The IDML spec reads:

The origin of the spread coordinate system is located at center of the spread. The left edge of the

first right hand page in the spread aligns with the horizontal center of the spread; the right edge of

the first left hand page in the spread appears to the left. The vertical centers of the pages align with

the vertical center of the spread. Each spread has its own coordinate system origin.

Did you read it before posting?

btw read in where?? in the specification document??

i'm new with indesign, so i'm still confused about itu.

that's mean the spread coordiante system is located at the center of the spread.

for example. i have 1 spread with 2 pages.

page no 1, width = 111 and height = 333

page no 2, width = 222 and height = 444

so the center of the spread is (111+222)/2 and (333+444)/2)?

(111+222)/2 for x,

(333+444)/2) for y?

• ###### 11. Re: [rotation at idml]

btw read in where?? in the specification document??

Yes.

http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/ID ML/idml-specification.pdf

that's mean the spread coordiante system is located at the center of the spread.

for example. i have 1 spread with 2 pages.

It certainly means that for a single page spread or a 2-page spread, such as your example. For a 3-page spread I am less certain, but I would expect it means the center of the center page. But again, it is trivial to test. So please test it!

• ###### 12. Re: [rotation at idml]

John Hawkinson wrote:

btw read in where?? in the specification document??

Yes.

http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/i ndesign/cs55-docs/IDML/idml-specification.pdf

that's mean the spread coordiante system is located at the center of the spread.

for example. i have 1 spread with 2 pages.

It certainly means that for a single page spread or a 2-page spread, such as your example. For a 3-page spread I am less certain, but I would expect it means the center of the center page. But again, it is trivial to test. So please test it!

okay.. thanks John..