From 8c48d69f06ddb3cb6c807a1e7db62dddb9778ded Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 4 Aug 2018 10:37:17 +0300 Subject: Use more basegfx deg<->rad functions, instead of direct formulas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Mike Kaganski --- .../reference/piecharttest/normal_pie_chart.txt | 6 +- .../controller/main/DragMethod_RotateDiagram.cxx | 6 +- chart2/source/tools/ThreeDHelper.cxx | 64 +++++++++++----------- chart2/source/view/axes/VCartesianAxis.cxx | 6 +- chart2/source/view/axes/VPolarAngleAxis.cxx | 2 +- chart2/source/view/charttypes/VSeriesPlotter.cxx | 2 +- chart2/source/view/main/AbstractShapeFactory.cxx | 2 +- chart2/source/view/main/LabelPositionHelper.cxx | 42 +++++++------- chart2/source/view/main/PlottingPositionHelper.cxx | 2 +- .../source/view/main/PolarLabelPositionHelper.cxx | 2 +- chart2/source/view/main/ShapeFactory.cxx | 20 ++++--- chart2/source/view/main/VPolarTransformation.cxx | 2 +- chart2/source/view/main/VTitle.cxx | 2 +- 13 files changed, 80 insertions(+), 78 deletions(-) (limited to 'chart2') diff --git a/chart2/qa/extras/chart2dump/reference/piecharttest/normal_pie_chart.txt b/chart2/qa/extras/chart2dump/reference/piecharttest/normal_pie_chart.txt index c009c97be800..1b97446cc2d8 100644 --- a/chart2/qa/extras/chart2dump/reference/piecharttest/normal_pie_chart.txt +++ b/chart2/qa/extras/chart2dump/reference/piecharttest/normal_pie_chart.txt @@ -35,15 +35,15 @@ 16728590 /// /D=0:CS=0:CT=0:Series=0:Point=2 // aSlicePosition.X -7678 +7679 // aSlicePosition.Y 1846 // aSliceSize.Height 3896 // aSliceSize.Width -3327 +3326 // aSliceTransformation -3327;0;7678;0;3896;1846;0;0;1 +3326;0;7679;0;3896;1846;0;0;1 // static_cast(aSliceFillStyle) 1 // static_cast(aSliceFillColor) diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx index 74bb7f7dd3a7..ccee914fdfbd 100644 --- a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx +++ b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx @@ -113,7 +113,7 @@ void DragMethod_RotateDiagram::MoveSdrDrag(const Point& rPnt) Hide(); //calculate new angle - double fX = F_PI / 2.0 * static_cast(rPnt.Y() - m_aStartPos.Y()) + double fX = F_PI2 * static_cast(rPnt.Y() - m_aStartPos.Y()) / (m_aReferenceRect.GetHeight() > 0 ? static_cast(m_aReferenceRect.GetHeight()) : 1.0); double fY = F_PI * static_cast(rPnt.X() - m_aStartPos.X()) / (m_aReferenceRect.GetWidth() > 0 ? static_cast(m_aReferenceRect.GetWidth()) : 1.0); @@ -140,8 +140,8 @@ void DragMethod_RotateDiagram::MoveSdrDrag(const Point& rPnt) + atan((fCx - rPnt.X())/(fCy-rPnt.Y())); } - m_nAdditionalHorizontalAngleDegree = static_cast(m_fAdditionalXAngleRad*180.0/F_PI); - m_nAdditionalVerticalAngleDegree = -static_cast(m_fAdditionalYAngleRad*180.0/F_PI); + m_nAdditionalHorizontalAngleDegree = static_cast(basegfx::rad2deg(m_fAdditionalXAngleRad)); + m_nAdditionalVerticalAngleDegree = -static_cast(basegfx::rad2deg(m_fAdditionalYAngleRad)); DragStat().NextMove(rPnt); Show(); diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx index 3967ce42868d..067642e5a149 100644 --- a/chart2/source/tools/ThreeDHelper.cxx +++ b/chart2/source/tools/ThreeDHelper.cxx @@ -404,8 +404,8 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad( double& y = rfYAngleRad; double& z = rfZAngleRad; - double E = F_PI*nElevationDeg/180; //elevation in Rad - double R = F_PI*nRotationDeg/180; //rotation in Rad + double E = basegfx::deg2rad(nElevationDeg); //elevation in Rad + double R = basegfx::deg2rad(nRotationDeg); //rotation in Rad if( (nRotationDeg == 0 || nRotationDeg == 180 ) && ( nElevationDeg == 90 || nElevationDeg == 270 ) ) @@ -415,20 +415,20 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad( //element 23 double f23 = cos(R)*sin(E); if(f23>0) - x = F_PI/2; + x = F_PI2; else - x = -F_PI/2; + x = -F_PI2; y = R; } else if( ( nRotationDeg == 90 || nRotationDeg == 270 ) && ( nElevationDeg == 90 || nElevationDeg == 270 ) ) { //cR==0 && cE==0 - z = F_PI/2; + z = F_PI2; if( sin(R)>0 ) - x = F_PI/2.0; + x = F_PI2; else - x = -F_PI/2.0; + x = -F_PI2; if( (sin(R)*sin(E))>0 ) y = 0.0; @@ -450,9 +450,9 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad( z = 0.0; if( (sin(R)/cos(E))>0 ) - y = F_PI/2; + y = F_PI2; else - y = -F_PI/2; + y = -F_PI2; if( (cos(E))>0 ) x = 0; @@ -477,9 +477,9 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad( z = atan(sin(R)/(cos(R)*sin(E))); //use element 13 for sign for x if( (sin(R)*sin(z))>0.0 ) - x = F_PI/2; + x = F_PI2; else - x = -F_PI/2; + x = -F_PI2; //use element 21 for y if( (sin(R)*sin(E)*sin(z))>0.0) y = 0.0; @@ -501,8 +501,8 @@ void ThreeDHelper::convertElevationRotationDegToXYZAngleRad( //sE!=0 cE!=0 cR==0 //z = +- F_PI/2; //x = +- F_PI/2; - z = F_PI/2; - x = F_PI/2; + z = F_PI2; + x = F_PI2; double sR = sin(R); if( sR<0.0 ) x *= -1.0; //different signs for x and z @@ -610,9 +610,9 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg( //element 23 double f23 = cos(z)*sin(x) / cos(R); if( f23 > 0 ) - E = F_PI/2.0; + E = F_PI2; else - E = -F_PI/2.0; + E = -F_PI2; } else if( lcl_isCosZero(z) ) { @@ -622,16 +622,16 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg( double f13 = sin(x)*sin(z); //element 13+11 if( f13 > 0 ) - R = F_PI/2.0; + R = F_PI2; else - R = -F_PI/2.0; + R = -F_PI2; //element 21 double f21 = cos(y)*sin(z) / sin(R); if( f21 > 0 ) - E = F_PI/2.0; + E = F_PI2; else - E = -F_PI/2.0; + E = -F_PI2; } else { @@ -646,9 +646,9 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg( //element 23 double f23 = cos(z)*sin(x); if( f23/cos(R) > 0 ) - E = F_PI/2.0; + E = F_PI2; else - E = -F_PI/2.0; + E = -F_PI2; } } else if( lcl_isSinZero(x) ) @@ -688,16 +688,16 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg( double f13 = sin(x)*sin(z); //element 13+11 if( f13 > 0 ) - R = F_PI/2.0; + R = F_PI2; else - R = -F_PI/2.0; + R = -F_PI2; //element 21+22 double f21 = cos(y)*sin(z); if( f21/sin(R) > 0 ) - E = F_PI/2.0; + E = F_PI2; else - E = -F_PI/2.0; + E = -F_PI2; } else { @@ -722,9 +722,9 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg( double f13 = sin(x)*sin(z)+cos(x)*cos(z)*sin(y); if( f13 >= 0 ) - R = F_PI/2.0; + R = F_PI2; else - R = -F_PI/2.0; + R = -F_PI2; double f22 = cos(x)*cos(z)+sin(x)*sin(y)*sin(z); if( f22 >= 0 ) @@ -790,20 +790,20 @@ void ThreeDHelper::convertXYZAngleRadToElevationRotationDeg( R=0;//13 -> R=0 or F_PI if( f11<0.0 ) R=F_PI; - E=F_PI/2;//22 -> E=+-F_PI/2 + E=F_PI2;//22 -> E=+-F_PI/2 //use element 11 and 23 for sign double f23 = cos(z)*sin(x); if( (f11*f23*sin(E))<0.0 ) - E=-F_PI/2.0; + E=-F_PI2; } else if( lcl_isCosZero(z) ) { //cosY!=0 sinY!=0 cosX=0 cosZ=0 //element 11 & 13: if( (sin(x)*sin(z))>0.0 ) - R=F_PI/2.0; + R=F_PI2; else - R=-F_PI/2.0; + R=-F_PI2; //element 22: E=acos( sin(x)*sin(y)*sin(z)); //use element 21 for sign: @@ -920,7 +920,7 @@ void ThreeDHelper::getRotationAngleFromDiagram( rfYAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getY()); rfZAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getZ()); - if(rfZAngleRad<(-F_PI/2) || rfZAngleRad>(F_PI/2)) + if(rfZAngleRad<-F_PI2 || rfZAngleRad>F_PI2) { rfZAngleRad-=F_PI; rfXAngleRad-=F_PI; diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 903e3b38405a..f88a45fe56dc 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -137,7 +137,7 @@ Reference< drawing::XShape > createSingleLabel( return nullptr; // #i78696# use mathematically correct rotation now - const double fRotationAnglePi(rAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0)); + const double fRotationAnglePi(-basegfx::deg2rad(rAxisLabelProperties.fRotationAngleDegree)); uno::Any aATransformation = AbstractShapeFactory::makeTransformation( rAnchorScreenPosition2D, fRotationAnglePi ); OUString aLabel = AbstractShapeFactory::getStackedString( rLabel, rAxisLabelProperties.bStackCharacters ); @@ -183,7 +183,7 @@ void lcl_getRotatedPolygon( B2DPolygon &aPoly, const ::basegfx::B2DRectangle &aR // which is then moved to its final position by using the top-left // vertex of the text label bounding box (aPos) as the translation vector. ::basegfx::B2DHomMatrix aMatrix; - aMatrix.rotate( -fRotationAngleDegree*M_PI/180.0 ); + aMatrix.rotate(-basegfx::deg2rad(fRotationAngleDegree)); aMatrix.translate( aPos.X, aPos.Y); aPoly.transform( aMatrix ); } @@ -1713,7 +1713,7 @@ void VCartesianAxis::updatePositions() } // #i78696# use mathematically correct rotation now - const double fRotationAnglePi(fRotationAngleDegree * (F_PI / -180.0)); + const double fRotationAnglePi(-basegfx::deg2rad(fRotationAngleDegree)); uno::Any aATransformation = AbstractShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi); //set new position diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index 64ec7be67d6f..bc13eb5830a9 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -121,7 +121,7 @@ void VPolarAngleAxis::createTextShapes_ForAngleAxis( LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, eLabelAlignment ); // #i78696# use mathematically correct rotation now - const double fRotationAnglePi(rAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0)); + const double fRotationAnglePi(-basegfx::deg2rad(rAxisLabelProperties.fRotationAngleDegree)); uno::Any aATransformation = AbstractShapeFactory::makeTransformation( aAnchorScreenPosition2D, fRotationAnglePi ); OUString aStackedLabel = AbstractShapeFactory::getStackedString( aLabel, rAxisLabelProperties.bStackCharacters ); diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 2172206fb8c8..a52911ee76da 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -724,7 +724,7 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re const awt::Point aUnrotatedTextPos( xTextShape->getPosition() ); if( fRotationDegrees != 0.0 ) { - const double fDegreesPi( fRotationDegrees * ( F_PI / -180.0 ) ); + const double fDegreesPi( -basegfx::deg2rad(fRotationDegrees) ); uno::Reference< beans::XPropertySet > xProp( xTextShape, uno::UNO_QUERY ); if( xProp.is() ) xProp->setPropertyValue( "Transformation", AbstractShapeFactory::makeTransformation( aScreenPosition2D, fDegreesPi ) ); diff --git a/chart2/source/view/main/AbstractShapeFactory.cxx b/chart2/source/view/main/AbstractShapeFactory.cxx index 6e85eb79a9ce..c6c718a2e4dc 100644 --- a/chart2/source/view/main/AbstractShapeFactory.cxx +++ b/chart2/source/view/main/AbstractShapeFactory.cxx @@ -271,7 +271,7 @@ awt::Size AbstractShapeFactory::getSizeAfterRotation( else if(fRotationAngleDegree>90.0) fRotationAngleDegree=180.0-fRotationAngleDegree; - const double fAnglePi = fRotationAngleDegree*F_PI/180.0; + const double fAnglePi = basegfx::deg2rad(fRotationAngleDegree); aRet.Height = static_cast( aSize.Width*rtl::math::sin( fAnglePi ) diff --git a/chart2/source/view/main/LabelPositionHelper.cxx b/chart2/source/view/main/LabelPositionHelper.cxx index 111a396a4b49..d97de691fc18 100644 --- a/chart2/source/view/main/LabelPositionHelper.cxx +++ b/chart2/source/view/main/LabelPositionHelper.cxx @@ -117,7 +117,7 @@ void lcl_correctRotation_Left( double& rfXCorrection, double& rfYCorrection , double fAnglePositiveDegree, const awt::Size& aSize, bool bRotateAroundCenter ) { //correct label positions for labels on a left side of something with a right centered alignment - double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + double fAnglePi = basegfx::deg2rad(fAnglePositiveDegree); if( fAnglePositiveDegree==0.0 ) { } @@ -129,7 +129,7 @@ void lcl_correctRotation_Left( double& rfXCorrection, double& rfYCorrection } else if( fAnglePositiveDegree<= 180.0 ) { - double beta = fAnglePi-F_PI/2.0; + double beta = fAnglePi-F_PI2; rfXCorrection = -aSize.Width *rtl::math::sin( beta ) -aSize.Height *rtl::math::cos( beta )/2.0; if( bRotateAroundCenter ) @@ -160,7 +160,7 @@ void lcl_correctRotation_Right( double& rfXCorrection, double& rfYCorrection , double fAnglePositiveDegree, const awt::Size& aSize, bool bRotateAroundCenter ) { //correct label positions for labels on a right side of something with a left centered alignment - double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + double fAnglePi = basegfx::deg2rad(fAnglePositiveDegree); if( fAnglePositiveDegree== 0.0 ) { } @@ -182,7 +182,7 @@ void lcl_correctRotation_Right( double& rfXCorrection, double& rfYCorrection } else if( fAnglePositiveDegree<= 270.0 ) { - double beta = 3*F_PI/2.0 - fAnglePi; + double beta = 3*F_PI2 - fAnglePi; rfXCorrection = aSize.Width *rtl::math::sin( beta ) +aSize.Height*rtl::math::cos( beta )/2.0; if( bRotateAroundCenter ) @@ -202,7 +202,7 @@ void lcl_correctRotation_Top( double& rfXCorrection, double& rfYCorrection , double fAnglePositiveDegree, const awt::Size& aSize, bool bRotateAroundCenter ) { //correct label positions for labels on top of something with a bottom centered alignment - double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + double fAnglePi = basegfx::deg2rad(fAnglePositiveDegree); if( fAnglePositiveDegree== 0.0 ) { } @@ -215,7 +215,7 @@ void lcl_correctRotation_Top( double& rfXCorrection, double& rfYCorrection } else if( fAnglePositiveDegree<= 180.0 ) { - double beta = fAnglePi - F_PI/2.0; + double beta = fAnglePi - F_PI2; rfXCorrection = aSize.Height*rtl::math::cos( beta )/2.0; if( !bRotateAroundCenter ) rfXCorrection -= aSize.Width*rtl::math::sin( beta )/2.0; @@ -244,7 +244,7 @@ void lcl_correctRotation_Bottom( double& rfXCorrection, double& rfYCorrection , double fAnglePositiveDegree, const awt::Size& aSize, bool bRotateAroundCenter ) { //correct label positions for labels below something with a top centered alignment - double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + double fAnglePi = basegfx::deg2rad(fAnglePositiveDegree); if( fAnglePositiveDegree==0.0 ) { } @@ -257,7 +257,7 @@ void lcl_correctRotation_Bottom( double& rfXCorrection, double& rfYCorrection } else if( fAnglePositiveDegree<= 180.0 ) { - double beta = fAnglePi-F_PI/2.0; + double beta = fAnglePi-F_PI2; rfXCorrection = -aSize.Height*rtl::math::cos( beta )/2.0; if( !bRotateAroundCenter ) rfXCorrection += aSize.Width *rtl::math::sin( beta )/2.0; @@ -266,7 +266,7 @@ void lcl_correctRotation_Bottom( double& rfXCorrection, double& rfYCorrection } else if( fAnglePositiveDegree<= 270.0 ) { - double beta = 3*F_PI/2.0 - fAnglePi; + double beta = 3*F_PI2 - fAnglePi; rfXCorrection = aSize.Height*rtl::math::cos( beta )/2.0; if( !bRotateAroundCenter ) rfXCorrection -= aSize.Width *rtl::math::sin( beta )/2.0; @@ -287,7 +287,7 @@ void lcl_correctRotation_Left_Top( double& rfXCorrection, double& rfYCorrection , double fAnglePositiveDegree, const awt::Size& aSize ) { //correct position for labels at the left top corner of something with a bottom right alignment - double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + double fAnglePi = basegfx::deg2rad(fAnglePositiveDegree); if( fAnglePositiveDegree==0.0 ) { } @@ -297,14 +297,14 @@ void lcl_correctRotation_Left_Top( double& rfXCorrection, double& rfYCorrection } else if( fAnglePositiveDegree<= 180.0 ) { - double beta = fAnglePi-F_PI/2.0; + double beta = fAnglePi-F_PI2; rfXCorrection = -aSize.Width*rtl::math::sin( beta ); rfYCorrection = -aSize.Height*rtl::math::sin( beta ) -aSize.Width*rtl::math::cos( beta ); } else if( fAnglePositiveDegree<= 270.0 ) { - double beta = 3*F_PI/2.0 - fAnglePi; + double beta = 3*F_PI2 - fAnglePi; rfXCorrection = -aSize.Height*rtl::math::cos( beta ) -aSize.Width*rtl::math::sin( beta ); rfYCorrection = -aSize.Height*rtl::math::sin( beta ); @@ -319,7 +319,7 @@ void lcl_correctRotation_Left_Bottom( double& rfXCorrection, double& rfYCorrecti , double fAnglePositiveDegree, const awt::Size& aSize ) { //correct position for labels at the left bottom corner of something with a top right alignment - double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + double fAnglePi = basegfx::deg2rad(fAnglePositiveDegree); if( fAnglePositiveDegree==0.0 ) { } @@ -329,14 +329,14 @@ void lcl_correctRotation_Left_Bottom( double& rfXCorrection, double& rfYCorrecti } else if( fAnglePositiveDegree<= 180.0 ) { - double beta = fAnglePi-F_PI/2.0; + double beta = fAnglePi-F_PI2; rfXCorrection = -aSize.Width*rtl::math::sin( beta ) -aSize.Height*rtl::math::cos( beta ); rfYCorrection = aSize.Height*rtl::math::sin( beta ); } else if( fAnglePositiveDegree<= 270.0 ) { - double beta = 3*F_PI/2.0 - fAnglePi; + double beta = 3*F_PI2 - fAnglePi; rfXCorrection = -aSize.Width*rtl::math::sin( beta ); rfYCorrection = aSize.Width*rtl::math::cos( beta ) +aSize.Height*rtl::math::sin( beta ); @@ -351,7 +351,7 @@ void lcl_correctRotation_Right_Top( double& rfXCorrection, double& rfYCorrection , double fAnglePositiveDegree, const awt::Size& aSize ) { //correct position for labels at the right top corner of something with a bottom left alignment - double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + double fAnglePi = basegfx::deg2rad(fAnglePositiveDegree); if( fAnglePositiveDegree==0.0 ) { } @@ -361,14 +361,14 @@ void lcl_correctRotation_Right_Top( double& rfXCorrection, double& rfYCorrection } else if( fAnglePositiveDegree<= 180.0 ) { - double beta = fAnglePi-F_PI/2.0; + double beta = fAnglePi-F_PI2; rfXCorrection = aSize.Width*rtl::math::sin( beta ) +aSize.Height*rtl::math::cos( beta ); rfYCorrection = -aSize.Height*rtl::math::sin( beta ); } else if( fAnglePositiveDegree<= 270.0 ) { - double beta = 3*F_PI/2.0 - fAnglePi; + double beta = 3*F_PI2 - fAnglePi; rfXCorrection = aSize.Width*rtl::math::sin( beta ); rfYCorrection = -aSize.Width*rtl::math::cos( beta ) -aSize.Height*rtl::math::sin( beta ); @@ -383,7 +383,7 @@ void lcl_correctRotation_Right_Bottom( double& rfXCorrection, double& rfYCorrect , double fAnglePositiveDegree, const awt::Size& aSize ) { //correct position for labels at the right bottom corner of something with a top left alignment - double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + double fAnglePi = basegfx::deg2rad(fAnglePositiveDegree); if( fAnglePositiveDegree==0.0 ) { } @@ -393,14 +393,14 @@ void lcl_correctRotation_Right_Bottom( double& rfXCorrection, double& rfYCorrect } else if( fAnglePositiveDegree<= 180.0 ) { - double beta = fAnglePi-F_PI/2.0; + double beta = fAnglePi-F_PI2; rfXCorrection = aSize.Width*rtl::math::sin( beta ); rfYCorrection = aSize.Height*rtl::math::sin( beta ) +aSize.Width*rtl::math::cos( beta ); } else if( fAnglePositiveDegree<= 270.0 ) { - double beta = 3*F_PI/2.0 - fAnglePi; + double beta = 3*F_PI2 - fAnglePi; rfXCorrection = aSize.Height*rtl::math::cos( beta ) +aSize.Width*rtl::math::sin( beta ); rfYCorrection = aSize.Height*rtl::math::sin( beta ); diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index da5cc4159aca..32aa4394127f 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -613,7 +613,7 @@ drawing::Position3D PolarPlottingPositionHelper::transformScaledLogicToScene( do drawing::Position3D PolarPlottingPositionHelper::transformUnitCircleToScene( double fUnitAngleDegree, double fUnitRadius , double fLogicZ ) const { - double fAnglePi = fUnitAngleDegree*F_PI/180.0; + double fAnglePi = basegfx::deg2rad(fUnitAngleDegree); double fX=fUnitRadius*rtl::math::cos(fAnglePi); double fY=fUnitRadius*rtl::math::sin(fAnglePi); diff --git a/chart2/source/view/main/PolarLabelPositionHelper.cxx b/chart2/source/view/main/PolarLabelPositionHelper.cxx index 07bf9e8bae85..ac2f1c50d317 100644 --- a/chart2/source/view/main/PolarLabelPositionHelper.cxx +++ b/chart2/source/view/main/PolarLabelPositionHelper.cxx @@ -109,7 +109,7 @@ awt::Point PolarLabelPositionHelper::getLabelScreenPositionAndAlignmentForUnitCi fDY*=-1.0;//drawing layer has inverse y values if( fDX != 0.0 ) { - fAngleDegree = atan(fDY/fDX)*180.0/F_PI; + fAngleDegree = basegfx::rad2deg(atan(fDY/fDX)); if(fDX<0.0) fAngleDegree+=180.0; } diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 696ca39da940..a5f58bcc3c25 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -898,10 +898,11 @@ uno::Reference< drawing::XShape > const double fAngleSubdivisionRadian = F_PI/10.0; - drawing::PolyPolygonBezierCoords aCoords = getRingBezierCoords( - fUnitCircleInnerRadius, fUnitCircleOuterRadius - , fUnitCircleStartAngleDegree*F_PI/180.0, fUnitCircleWidthAngleDegree*F_PI/180.0 - , aTransformationFromUnitCircle, fAngleSubdivisionRadian ); + drawing::PolyPolygonBezierCoords aCoords + = getRingBezierCoords(fUnitCircleInnerRadius, fUnitCircleOuterRadius, + basegfx::deg2rad(fUnitCircleStartAngleDegree), + basegfx::deg2rad(fUnitCircleWidthAngleDegree), + aTransformationFromUnitCircle, fAngleSubdivisionRadian); xProp->setPropertyValue( "PolyPolygonBezier", uno::Any( aCoords ) ); } @@ -949,10 +950,11 @@ uno::Reference< drawing::XShape > const double fAngleSubdivisionRadian = F_PI/32.0; - drawing::PolyPolygonBezierCoords aCoords = getRingBezierCoords( - fUnitCircleInnerRadius, fUnitCircleOuterRadius - , fUnitCircleStartAngleDegree*F_PI/180.0, fUnitCircleWidthAngleDegree*F_PI/180.0 - , aTransformationFromUnitCircle, fAngleSubdivisionRadian ); + drawing::PolyPolygonBezierCoords aCoords + = getRingBezierCoords(fUnitCircleInnerRadius, fUnitCircleOuterRadius, + basegfx::deg2rad(fUnitCircleStartAngleDegree), + basegfx::deg2rad(fUnitCircleWidthAngleDegree), + aTransformationFromUnitCircle, fAngleSubdivisionRadian); //depth xProp->setPropertyValue( UNO_NAME_3D_EXTRUDE_DEPTH @@ -2502,7 +2504,7 @@ uno::Reference< drawing::XShape > //set position matrix //the matrix needs to be set at the end behind autogrow and such position influencing properties ::basegfx::B2DHomMatrix aM; - aM.rotate( -nRotation*F_PI/180.0 );//#i78696#->#i80521# + aM.rotate( -basegfx::deg2rad(nRotation) );//#i78696#->#i80521# aM.translate( nXPos, nYPos ); xShapeProp->setPropertyValue( "Transformation", uno::Any( B2DHomMatrixToHomogenMatrix3(aM) ) ); } diff --git a/chart2/source/view/main/VPolarTransformation.cxx b/chart2/source/view/main/VPolarTransformation.cxx index 0692c6130c56..a82bc9961a81 100644 --- a/chart2/source/view/main/VPolarTransformation.cxx +++ b/chart2/source/view/main/VPolarTransformation.cxx @@ -51,7 +51,7 @@ Sequence< double > SAL_CALL VPolarTransformation::transform( std::swap(fScaledLogicAngle,fScaledLogicRadius); double fAngleDegree = m_aPositionHelper.transformToAngleDegree( fScaledLogicAngle, false ); - double fAnglePi = fAngleDegree*F_PI/180.0; + double fAnglePi = basegfx::deg2rad(fAngleDegree); double fRadius = m_aPositionHelper.transformToRadius( fScaledLogicRadius, false); double fX=fRadius*cos(fAnglePi); diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx index 7b74b93da35b..43f7a42b3337 100644 --- a/chart2/source/view/main/VTitle.cxx +++ b/chart2/source/view/main/VTitle.cxx @@ -62,7 +62,7 @@ void VTitle::init( double VTitle::getRotationAnglePi() const { - return m_fRotationAngleDegree*F_PI/180.0; + return basegfx::deg2rad(m_fRotationAngleDegree); } awt::Size VTitle::getUnrotatedSize() const //size before rotation -- cgit