RFC: Sane rectangle class

Noel Grandin noelgrandin at gmail.com
Mon Mar 23 17:39:41 UTC 2020

On Mon, 23 Mar 2020 at 17:12, Luboš Luňák <l.lunak at collabora.com> 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

For the common case of rendering spreadsheets and text, integer
co-ordinates are better behaved.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20200323/d0b675c8/attachment.htm>

More information about the LibreOffice mailing list