Hi,
Very new to this forum so please forgive me if I type any text in wrong!
I was wondering how I the tag : transform matrix is used. I have a rotated rectangle in Inkscape and it adds the transform matrix tag, how are the
6 values of it used? If I got an xpos of say 200 and ypos of 300, how can I use the contents of this matrix to transform it, i.e. rotate it?
Do I just multiply the x and y position with the matrix (a b c d e f) ? I'm presuming e and f are the translated x and y positions and a b c d are the
rotations?
Many thanks,
Steve
Transform matrix
Re: Transform matrix
I'm convinced there is something wrong with the x and y coordinates in inkscape when you apply a rotation - they seem to be all over the place, either that or I am completely being stupid?!
When I have a rectangle and I apply a rotation of say 45 degs, it does the usual transform matrix, but the x and y attributes when looking at the xml just don't seem to be inline with that on the screen, what is wrong?!?!?!?!? Is it doing rotation then translation or something, sometimes I get negative xpositions when the ruler guide is showing the rectangle x position should be at a positive value...is this a bug???
I'm so confused with this now.
When I have a rectangle and I apply a rotation of say 45 degs, it does the usual transform matrix, but the x and y attributes when looking at the xml just don't seem to be inline with that on the screen, what is wrong?!?!?!?!? Is it doing rotation then translation or something, sometimes I get negative xpositions when the ruler guide is showing the rectangle x position should be at a positive value...is this a bug???
I'm so confused with this now.
Re: Transform matrix
The best reference to how to use the transform matrix is probably the w3c specification: http://www.w3.org/TR/SVG/coords.html#Tr ... rixDefined
You can also use a rotate(), scale(), translate() and skewX() inside the transform attribute which is easier to understand for humans. See here: http://apike.ca/prog_svg_transform.html
Inkscape creates the matrix method because it's more general so the same code can cope with all the options, but can also process the other types.
You can also use a rotate(), scale(), translate() and skewX() inside the transform attribute which is easier to understand for humans. See here: http://apike.ca/prog_svg_transform.html
Inkscape creates the matrix method because it's more general so the same code can cope with all the options, but can also process the other types.
Re: Transform matrix
I can't comment on the matrix questions and why e.g. when rotating a rectangle (an Inkscape shape, not a path) the base point (x,y) is translated as well as a matrix applied. But one thing that confused me early on - there are two coordinate systems in play:steg90 wrote:but the x and y attributes when looking at the xml just don't seem to be inline with that on the screen, what is wrong?
- Inkscape GUI: origin lower left corner of the page, y-axis pointing up, units: default document units
- SVG source: origin upper left corner of the page, y-axis pointing down, units: px
Re: Transform matrix
Hi,
Looks like Inkscape is rotating and then translating? I just want to rotate a rectangle and have it to be at its original x,y position, not to have some very silly x,y value that don't seem to match with the gui grid in inkscape.
Tomh - how do you put the rotate into the transform attribute, everytime I apply a rotation, the xml shows transform matrix(.....)?!
Regards,
Steve
Looks like Inkscape is rotating and then translating? I just want to rotate a rectangle and have it to be at its original x,y position, not to have some very silly x,y value that don't seem to match with the gui grid in inkscape.
Tomh - how do you put the rotate into the transform attribute, everytime I apply a rotation, the xml shows transform matrix(.....)?!
Regards,
Steve
Re: Transform matrix
Looks like Inkscape is rotating and then translating? I just want to rotate a rectangle and have it to be at its original x,y position, not to have some very silly x,y value that don't seem to match with the gui grid in inkscape.
Inkscape has a concept of a rotation centre so when rotation is done from within Inkscape, it will happen about this:
see http://en.flossmanuals.net/Inkscape/SelectorTool under "Rotating" and "Rotation centre" headings
If you are hand editing the XML, then things get a bit more tricky, as the rotation is done about the co-ordinate system origin (In svg normally top left page border), although this can get transformed again to be the "user co-ordinate system": I don't understand this though! You would have to manually specify the correct displacement to the centre of the object you want to rotate.
Tomh - how do you put the rotate into the transform attribute, everytime I apply a rotation, the xml shows transform matrix(.....)?!
Yes, this is a bug in Inkscape. Inkscape knows how to do the rotate()->matrix() conversion, and uses this to display the rotation, however in the process it forgets the original rotate(). See: https://bugs.launchpad.net/inkscape/+bug/179309 It's an old bug...
Re: Transform matrix
So like previously said. is there a way to get the exact x,y coordinates of a rectangle when it's been rotated. a non-rotated rectangle works fine but the moment it rotates the x and y get screwed up. I'm trying to use inkscape as a level editor which it seems to be perfect for. I'm basically just using it to export collision data for box2D physics engine which I have it all working as long as the rectangle doesn't get rotated. I really need to know how to get consistent coordinates. Or at least understand what's happening to the x and y after rotation so I can get the right values into my program.
Any help at all is much appreciated.
thanks,
Artimus
Any help at all is much appreciated.
thanks,
Artimus