transformation inaccuracies

Bug #165360 reported by Swingincelt-users
2
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Medium
Unassigned

Bug Description

I noticed the transformations applied to objects is
quite inaccurate:

  <rect
     width="200.000000"
     height="200.000000"
     x="100.000000"
     y="100.000000"

style="font-size:12;fill:#808080;fill-rule:evenodd;stroke-width:1pt;&q
uot;
     id="rect562" />

Opening the transformations dialog and applying 10
horizontal gives this:

  <rect
     width="200.000000"
     height="200.000000"
     x="112.500000"
     y="99.9999695"

style="font-size:12;fill:#808080;fill-rule:evenodd;stroke-width:1pt;&q
uot;
     id="rect562" />

Also, If I take that original square and rotate it 10,
I get this:

  <rect
     width="200.000000"
     height="200.000000"
     x="62.2319183"
     y="131.691177"

transform="matrix(0.984808,-0.173648,0.173648,0.984808,0.000000,0.0000
00)"

style="font-size:12;fill:#808080;fill-rule:evenodd;stroke-width:1pt;&q
uot;
     id="rect562" />

Why have x and y changed? Shouldn't the matrix handle
all aspects of the transformation and leave x and y as
they were?

Revision history for this message
Peter Moulder (pjrm) wrote :

Re ".9999" with translation:
I have made it use doubles rather than floats for some of
the calculation, which reduces the error in this case to
small enough not to show up in the decimal representation.
Of course better would be to reduce the number of
conversions between coordinate systems; nevertheless, using
doubles is a sufficient fix for this particular example, and
I'm content to consider that part of the bug report addressed.

Re adding 12.5 rather than 10:
the default unit for SVG diagrams is a CSS2-style "pixel"
(see
http://www.w3.org/TR/REC-CSS2/syndata.html#length-units).
If translation is only to change the coordinates rather than
introduce a new coordinate system, then taking 1px to be a
fixed length of 1/90 of an inch is probably the best thing
to do.
Possible improvements:
  - Add a new item to the Units popup menu that uses the
shape's coordinate system, allowing a closer correspondance
between the number in the dialog box and the change in the
XML. However, I don't know if this is possible if multiple
shapes are selected (possibly having different coordinate
systems).
  - Don't convert between different bases (absolute vs
angular etc.); add an explicit transform if necessary.

Re rotation: I haven't checked the maths, but visually the
behaviour appears correct: it is rotating the shape about
the shape's centre, which makes the top-left coordinates change.

Revision history for this message
Buliabyak-users (buliabyak-users) wrote :

In the top panel, the coordinate of 100 is displayed as 80
(if the unit is pt), adding 10 to it displays 90 and writes
112.5 to the file, which is consistent. Adding "SVG pixel"
unit is possible but I'm not sure if it is really needed.
The 0.999 is fixed.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.