Re: RFC: Sane rectangle class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Mon, 23 Mar 2020 at 17:12, Luboš Luňák <l.lunak@xxxxxxxxxxxxx> wrote:
> I see the problem not in tools::Rectangle itself, but in the fact, that
> it uses integer and not double. Using double makes width = right - left
> in all cases
> and would solve accuracy problems in manipulating shapes.
> It would be up to renderer to do a suitable conversion to integer.

 I don't think using double magically solves everything. The same result can
be obtained by defining 'width = right - left' with integers, and I think I
can mis-count pixels as doubles just as well.


Correct. Using floating point for rendering trades one set of problems for another set of problems.
It is very easy to apply a set of transformations on floating point that accumulate error, resulting in 
bad output. It is also becomes quite hard to determine if an object is still in the same place after a set of transformations,
even if mathematically the set of transforms ===> identity.
This is why we have ::approxEqual appearing around the place, which doesn't always work.

Floating point is a fine choice for certain kinds of last-stage rendering inside the graphics card, and for other use-cases (like CAD), quite it is unavoidable.

For the common case of rendering spreadsheets and text, integer co-ordinates are better behaved.

_______________________________________________
LibreOffice mailing list
LibreOffice@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/libreoffice

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux