diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-08-04 10:37:17 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-08-04 20:51:27 +0200 |
commit | 8c48d69f06ddb3cb6c807a1e7db62dddb9778ded (patch) | |
tree | 8b6bf137be41ebe93746c4958ab9106bbf5cc339 /basegfx/source/polygon | |
parent | c05fbde6c870b7e6bc2f9bf642dc7d76215a496f (diff) |
Use more basegfx deg<->rad functions, instead of direct formulas
Also make the functions constexpr.
Due to slight changes in floating-point arithmetics (90.0 instead of
180.0, M_PI2 instead of M_PI resp.), results might differ in last
digits (usually 17th decimal digit). This has lead to need to tweak
char2dump's PieChartTest unit test.
Change-Id: I20323dd7dab27e4deb408ea4181e390cc05e7cd3
Reviewed-on: https://gerrit.libreoffice.org/58583
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basegfx/source/polygon')
-rw-r--r-- | basegfx/source/polygon/b2dlinegeometry.cxx | 2 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dsvgpolypolygon.cxx | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx b/basegfx/source/polygon/b2dlinegeometry.cxx index d9c24377a16e..ca4b88238383 100644 --- a/basegfx/source/polygon/b2dlinegeometry.cxx +++ b/basegfx/source/polygon/b2dlinegeometry.cxx @@ -104,7 +104,7 @@ namespace basegfx // from that vector, take the needed rotation and add rotate for arrow to transformation const B2DVector aTargetDirection(aHead - aTail); - const double fRotation(atan2(aTargetDirection.getY(), aTargetDirection.getX()) + (90.0 * F_PI180)); + const double fRotation(atan2(aTargetDirection.getY(), aTargetDirection.getX()) + F_PI2); // rotate around docking position aArrowTransform.rotate(fRotation); diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx index 4522ec94f99b..2de0daf1e82f 100644 --- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx +++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx @@ -489,7 +489,8 @@ namespace basegfx // |y1'| = |-sin phi cos phi| |(y1 - y2)/2| const B2DPoint p1(nLastX, nLastY); const B2DPoint p2(nX, nY); - B2DHomMatrix aTransform(basegfx::utils::createRotateB2DHomMatrix(-fPhi*M_PI/180)); + B2DHomMatrix aTransform(basegfx::utils::createRotateB2DHomMatrix( + -deg2rad(fPhi))); const B2DPoint p1_prime( aTransform * B2DPoint(((p1-p2)/2.0)) ); @@ -581,7 +582,7 @@ namespace basegfx aTransform = basegfx::utils::createScaleB2DHomMatrix(fRX, fRY); aTransform.translate(aCenter_prime.getX(), aCenter_prime.getY()); - aTransform.rotate(fPhi*M_PI/180); + aTransform.rotate(deg2rad(fPhi)); const B2DPoint aOffset((p1+p2)/2.0); aTransform.translate(aOffset.getX(), aOffset.getY()); |