Issue 99915 - very small values cause a broken chart display
Summary: very small values cause a broken chart display
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: chart (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: sgautier.ooo
QA Contact: issues@graphics
URL:
Keywords: regression
: 102507 103363 (view as issue list)
Depends on:
Blocks:
 
Reported: 2009-03-05 10:28 UTC by IngridvdM
Modified: 2013-02-24 21:21 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
example showing the problem (15.49 KB, application/vnd.oasis.opendocument.presentation)
2009-03-05 10:30 UTC, IngridvdM
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description IngridvdM 2009-03-05 10:28:44 UTC
Load the attached document and look at the chart. The red background should be
behind the axis and grid lines, instead it is moved to the top. The chart with
its axis and grid lines should fill almost the whole rectangle, there should be
not all that space wasted below and above.
Comment 1 IngridvdM 2009-03-05 10:30:33 UTC
Created attachment 60738 [details]
example showing the problem
Comment 2 IngridvdM 2009-03-05 10:32:46 UTC
@weiz, please have look.
Comment 3 weiz 2009-04-03 04:02:19 UTC
@iha: the error is caused by the value "mfSmallValue" at
basegfx\source\numeric\ftools.cxx.
 
In the example document, when translate the minimum y value
"aMatrix.translate(0.0, -MinY, 0.0);" at
"PlottingPositionHelper::getTransformationScaledLogicToScene()", the "-MinY" is
smaller than the mfSmallValue(1.0E-9), so "-MinY" is treated as Zero.

In the example document, when translate the minimum y value
"aMatrix.translate(0.0, -MinY, 0.0);" at
"PlottingPositionHelper::getTransformationScaledLogicToScene()", the "-MinY" is
smaller than the mfSmallValue(1.0E-9), so "-MinY" is treated as Zero.

If call fTools::setSmallValue to set a small value which is smaller than the
minimum value, the result it correct. But I don't know whether it will cause
other problems. 
Please let me know your suggestions. Thank you!
Comment 4 IngridvdM 2009-04-03 12:26:25 UTC
@aw, within the chart we need more accurate matrix calculations as currently
possible with the default value mfSmallValue. As this is a global static
variable it cannot be changed for chart usage only. Can you suggest what to do
here? Thanks!
Comment 5 Armin Le Grand 2009-04-03 13:35:29 UTC
AW->IHA: That small value is well balanced to make all kind of linear algebra
stuff work with the double precision values which sadly are not natural
mathematical numbers, but only try to come close to them. All kinds of precision
problems will arise when You change that number, so no, You cannot change it.
All algorithms using the non-ednless double precision values need to be balanced
with a restricting precision value (maybe You will again not believe me here, in
that case look in the net for answers :-).
That small number would even have to be smaller when we would decide to go from
doubles to floats.
The standard convention normally used in basegfx is to have the function call in
a second version where the small number is handed over as last parameter, see
various examples by grepping basegfx. This would mean to add below

		void translate(double fX, double fY);

a second method with

		void translate(double fX, double fY,  const double& rfSmallValue);

and to implement it accordingly by handing over that value to the used
fTools::equalZero tests which have a SmallValue supportig version. When You do
this, please take the time to add all necessary calls to the implementation of
B2DHomMatrix, others may need it in the future, too.

Another possibility is that You have a numerical problem with floating point in
the sense of numerical mathematics: You may use the wrong numerical method. If
that translation is an added translation with thousands of small moves, the
numerical way is not to translate thousands of time by the small value, but to
collect the combined translation locally and to apply a single one. Tis is done
for precision reasons and was stated in the 70's together with IEEE formats (in
fortran77 at that time).

I will add thb to cc, he may have more information on the topic if needed.
Comment 6 Armin Le Grand 2009-04-03 13:41:03 UTC
AW: Another comment to Your (beloved? :-)) broken and regression flags: That
behaviour has always been in basegfx (since it's been necessary from the start)
and has never been changed, so this cannot have come up from basegfx changes.
Comment 7 IngridvdM 2009-04-03 13:55:55 UTC
@aw, the regression flag is absolutely correct. Load the attached file with
OpenOffice.org 2.2 and double click the chart you can see that it was rendered
correctly. Starting with OOo 2.3 where the chart started to use basegfx matrices
the chart rendering of this file is broken.
Comment 8 IngridvdM 2009-04-03 14:31:37 UTC
@aw, thb, adding an additional parameter to several methods at the matrix
classes seems quite unhandy to me. What an ugly interface to use (and
implement). Wouldn't it make more sense to add the precision limit as a member
to the matrix class?
Furthermore the current precision limit:
double ::basegfx::fTools::mfSmallValue = 0.000000000001;
seems to me to be optimized for graphical display purposes where operations
might mostly happen in orders of magnitude of typical pixel counts or cm. That's
quite ok if one looks at the namspace of this matrix classes.
So maybe the use of the basegfx matrices for more general mathematical
calculations is not the right choice. Can one of you suggest another matrix
class? Or have the basegfx matrix classes the claim to be all purpose matrices?
Thank you for sharing your thoughts on your classes with the users of your classes.

Comment 9 IngridvdM 2009-04-03 14:39:32 UTC
small correction, the current limit is:
double ::basegfx::fTools::mfSmallValue = 0.000000001;
Comment 10 Armin Le Grand 2009-04-03 15:32:01 UTC
AW: I'm sorry that You think the interface is ugly, thb and i designed it
carefully. Adding the value to each incarnation of a matrix would bloat memory
and solve only for matrices. We offered possibilities to hand over an own small
value where needed, but it's implemented as needed. You are the first who
requests it for matrices.
The current small value has nothing to do with screen pixels or cm at all, but
only with double precision using IEEE 754 (AFAIK, see
http://de.wikipedia.org/wiki/Gleitkommazahl for more infos) where the number is
64bit, divided in exponent (11) and mantisse (52). In that sense, the matrix
class is not designed for graphics, but for common purpose. I see no hindrance
in expanding the interface in the suggested way.
Comment 11 IngridvdM 2009-04-03 15:40:50 UTC
@weiz, please implement this as aw has decided. Thanks!
Comment 12 thb 2009-04-06 15:49:05 UTC
Nothing substantial to add; only the canonical ptr to
http://www.physics.ohio-state.edu/~dws/grouplinks/floating_point_math.pdf

The problem here is the special case for comparing against zero (which does not
allow for relative precision calculation) - what I don't recall here is what the
checks at translate() were for, @aw, were there cases of catastrophic
cancellation you recall?
Comment 13 thb 2009-04-06 15:55:35 UTC
Oh, one additional note: if there's a need for a general-purpose matrix class
(that also handles much larger matrices), please use boost's
http://www.boost.org/doc/libs/1_38_0/libs/numeric/ublas/doc/index.htm
Comment 14 IngridvdM 2009-06-08 09:24:22 UTC
*** Issue 102507 has been marked as a duplicate of this issue. ***
Comment 15 IngridvdM 2009-06-24 09:25:36 UTC
weiz, as discussed in weekly IRC chat I take this issue back for fixing. Thanks
again for finding the reason of this problem.
Comment 16 IngridvdM 2009-06-24 09:30:23 UTC
Fixed in CWS chart39. I changed the order of translation and scaling operations
accordingly within chart so there is no collision with the current behavior of
the basegfx matrices anymore.
Comment 17 IngridvdM 2009-07-01 10:22:21 UTC
@Sophie, please verify in CWS chart39. Thanks, Ingrid!
Load the attached document and look at the chart. At first you will see how it
looks wrong, because only a replacement image is displayed that was wrongly
created before. Now double click on the chart to trigger a new rendering. The
expected result is that the red background now is within the rectangle defined
by the axis.
Comment 18 sgautier.ooo 2009-07-02 10:48:24 UTC
Verified in CWS chart39 - Red background is displayed within axis rectangle
after editing. Sophie
Comment 19 Regina Henschel 2009-07-07 18:06:51 UTC
*** Issue 103363 has been marked as a duplicate of this issue. ***
Comment 20 sgautier.ooo 2009-08-05 13:31:47 UTC
Verified in DEV300m54 - Closing - Sophie