Erros in transformation algebra

This is NOT a support forum. You are welcome to discuss software issues here, but all issues should be reported on Launchpad if you want them fixed.
JakeK
Posts: 5
Joined: Wed Sep 10, 2008 4:56 am

Erros in transformation algebra

Postby JakeK » Thu Sep 11, 2008 10:02 am

I made a rectangle
x-orig 1.515
y-orig 7.528
Width 51.248
Height 25.913

Using Object -> Transform -> Scale I doubled the rectangle and got
x-orig -24.109 wrong
y-orig -5.428 wrong
Width 102.495 correct
Height 51.826 correct

Using Object -> Transform -> Matrix I doubled the rectangle and got
x-orig 3.029 correct
y-orig 15.057 correct
Width 102.495 correct
Height 51.826 correct

Using "transform="scale(2.0,2.0)" I doubled the rectangle and got
x-orig 3.029 correct
y-orig -24.943 wrong
Width 102.495 correct
Height 51.826 correct

Using transform="matrix(2.0,0,0,2.0,0,0)" I doubled the rectangle and got
x-orig 3.029 correct
y-orig -24.495 wrong
Width 102.495 correct
Height 51.826 correct

1 out of 4 ain't bad but the wrong answers are not even consistent. It would be great if the Inkscape devs could improve on this great software by fixing this.

User avatar
loonquawl
Posts: 135
Joined: Thu May 15, 2008 7:57 pm

Re: Erros in transformation algebra

Postby loonquawl » Thu Sep 11, 2008 5:24 pm

Why do you call the Transform->Scale product wrong?
the x and y origin shift by 1/2 width and heigth, respectively, in other words, the center of the rectangle stays where it is. That is as should be.

When manually scaling it (with the mouse), you can press Shift to switch between Scaling 'Out of the middle' or 'Out of the corner' .
The transform Matrix works from the left upper corner of the Canvas, imagine your object on a rubber sheet, that is fixed in the corner. To scale with the Matrix, youpull the sheet, so if you double the size of the object, you double its distance to the corner, too.

JakeK
Posts: 5
Joined: Wed Sep 10, 2008 4:56 am

Re: Erros in transformation algebra

Postby JakeK » Fri Sep 12, 2008 4:45 am

When trying to find a work-around to the scaling problem I tried to place a rectangle in each of the 4 quadrants. No problem manually. With XML when I place a rectangle at:
id="rect2382"
width="30"
height="10"
x="10"
y="-20" />
it came out on the screen at:
30.5 width
10.5 height
9.75 x
49.75 y

I am totally stymied by the y value. This may have something to do with the transformation inconsistency discussed earlier. Can somebody explain this for me?

Looking at the W3C spec (Section 7.5) it describes a purely linear algebra approach to transformations. AFAIK this always uses the lower left corner as the origin. If one follows this rule, then nesting transformation is straightforward -- otherwise one has to devise methodology for keeping track of all the side-effects. These side-effects will really rise up to bite in the end. (How do you like that mixed metaphor.)

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Erros in transformation algebra

Postby sas » Fri Sep 12, 2008 5:53 am

The y-value is due to Inkscape using a y-axis that goes up, while SVG uses a y-axis that goes down (section 7.3 of the spec).

The remaining 0.25 difference is presumably due to a stroke of width 0.5.

JakeK
Posts: 5
Joined: Wed Sep 10, 2008 4:56 am

Re: Erros in transformation algebra

Postby JakeK » Fri Sep 12, 2008 6:51 am

Thanks for the help. It is really helpful.

This sorta suggests that one cannot use 3 and 4 quadrants when using SVG with inkscape
-- keeping track of the transforms would be horrendous. Too bad -- manipulating an image with its XML representation is very attractive.

JakeK
Posts: 5
Joined: Wed Sep 10, 2008 4:56 am

Re: Erros in transformation algebra

Postby JakeK » Fri Sep 12, 2008 9:54 am

Aha, thanks to sas who pointed out that svg operates in windows dos space where y-axis grows down I figured it out (I think). The question is where does it grow down from -- ans from the top edge of the page. Hence the mapping from svg space to inkspace space is quite simple and do-able. (I think)

Thanks again for your help.


Return to “Discuss Software Issues”