# xmlgraphics-batik-users mailing list archives

##### Site index · List index
Message view
Top
From Andrew Plotkin <erkyr...@eblong.com>
Subject RE: Extracting information from a transformation matrix
Date Thu, 01 Jun 2006 18:10:22 GMT
```On Thu, 1 Jun 2006, Bishop, Michael W. CONTR J9C880 wrote:

> All right, this is great information.  I need to sit down and work
> through it with my SVG Matrix algebra examples in front of me.  I do
> have a couple of questions:
>
> - Assuming I already have the center poitns, I could derive all the
> values I wanted right?  The rotate(t, x, y) command is a shortcut for
> translation if I remember right.  It's short for translate(x,y)
> rotate(t) translate(-x,-y) isn't it?

Yes.

If you already know the cx and cy, you can work everything out, yes. Let
me take a look at my example...

<ellipse id="sall" transform="translate(4,4) scale(3) rotate(60,1,2)"
rx="1" ry="2" />

cx,cy = (1,2)   (we know this in advance)
translate=(10.69615268,4.401909828)
scale=3
rotate=60

The scale and rotate values are correct. We just need to fix the
translation.

(This is where we start applying some Experimental Mathematics. Which is
to say, I'm going to rearrange the equations until the right answers come
out. :)

Scale and rotate the cx,cy vector by the values we've worked out. (We're

newcx = scale * (cx*cos(rotate*pi/180) + cy*sin(rotate*pi/180))
= 3 * (1*cos(60*pi/180) + 2*sin(60*pi/180))
= 6.69615241552696
newcy = scale * (cy*cos(rotate*pi/180) - cx*sin(rotate*pi/180))
= 3 * (2*cos(60*pi/180) - 1*sin(60*pi/180))
= 0.401923908261826

Then to work out the original translation values, take the values above
and subtract (newcx, newcy)

(10.69615268,4.40190982) - (6.69615241,0.40192390) = (4,4)

> - Does the order matter?  In the app, you can scale, rotate, and
> translate in any order.

Yes, the order matters. If you translate after you scale, you'll have to
unscale the translation values (divide them by the scale). If you
translate after you rotate, you'll have to unrotate them (apply some more
trig). Go through some examples and it should be obvious.

The order of scale and rotate doesn't matter. (As you can see: rotating a
shape and then scaling it produces the same result as scaling it and then
rotating it.)

--Z

--
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
*
If the Bush administration hasn't thrown you in military prison
without trial, it's for one reason: they don't feel like it. Not
because of the Fifth Amendment.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org