chart2/source/view/main/PolarLabelPositionHelper.cxx | 15 ------- hwpfilter/source/hwpreader.cxx | 39 +------------------ 2 files changed, 5 insertions(+), 49 deletions(-)
New commits: commit 25ac6754d144a258d39cd9251677f3e35f4b3ee6 Author: Dhiraj Holden <dhiraj.hol...@gmail.com> AuthorDate: Tue Nov 30 15:44:00 2021 -0500 Commit: Hossein <hoss...@libreoffice.org> CommitDate: Wed Dec 15 01:32:43 2021 +0100 tdf#145630 Changed atan to atan2 where appropriate The extra checks are superfluous with atan2, and thus removed. More information can be found here: https://dev.blog.documentfoundation.org/2021/11/17/use-atan2-function-instead-of-atan-easyhack/ Change-Id: I1de97562ce3f7180ce846629870915f789a7bedf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126212 Tested-by: Jenkins Reviewed-by: Hossein <hoss...@libreoffice.org> diff --git a/chart2/source/view/main/PolarLabelPositionHelper.cxx b/chart2/source/view/main/PolarLabelPositionHelper.cxx index 8ebe9ca4c4cc..b64de3970196 100644 --- a/chart2/source/view/main/PolarLabelPositionHelper.cxx +++ b/chart2/source/view/main/PolarLabelPositionHelper.cxx @@ -104,19 +104,8 @@ awt::Point PolarLabelPositionHelper::getLabelScreenPositionAndAlignmentForUnitCi double fDX = aRet.X-aP0.X; double fDY = aRet.Y-aP0.Y; fDY*=-1.0;//drawing layer has inverse y values - if( fDX != 0.0 ) - { - fAngleDegree = basegfx::rad2deg(atan(fDY/fDX)); - if(fDX<0.0) - fAngleDegree+=180.0; - } - else - { - if(fDY>0.0) - fAngleDegree = 90.0; - else - fAngleDegree = 270.0; - } + + fAngleDegree = basegfx::rad2deg(atan2(fDY,fDX)); } //set LabelAlignment if( !bCenter ) diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index 32d9b08c6d25..e26cbb26143a 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -4046,16 +4046,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) double rotate, skewX ; /* 2 - rotation angle calculation */ - if( pt[1].x == pt[0].x ){ - if( pt[1].y > pt[0].y ) - rotate = M_PI_2; - else - rotate = -M_PI_2; - } - else - rotate = atan(static_cast<double>( pt[1].y - pt[0].y )/(pt[1].x - pt[0].x )); - if( pt[1].x < pt[0].x ) - rotate += M_PI; + rotate = atan2( pt[1].y - pt[0].y, pt[1].x - pt[0].x ); for( i = 0 ; i < 3 ; i++){ r_pt[i].x = static_cast<int>(pt[i].x * cos(-rotate) - pt[i].y * sin(-rotate)); @@ -4261,33 +4252,9 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) double start_angle, end_angle; ZZParall *pal = &drawobj->property.parall; - if( pal->pt[1].x == pal->pt[0].x ){ - if( pal->pt[0].y < pal->pt[1].y ) - start_angle = 3 * M_PI_2; - else - start_angle = M_PI_2; - } - else{ - start_angle = atan(static_cast<double>( pal->pt[0].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[0].x )); - if( pal->pt[1].x < pal->pt[0].x ) - start_angle += M_PI; - } - if( pal->pt[1].x == pal->pt[2].x ){ - if( pal->pt[2].y < pal->pt[1].y ) - end_angle = 3 * M_PI_2; - else - end_angle = M_PI_2; - } - else{ - end_angle = atan(static_cast<double>( pal->pt[2].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[2].x )); - if( pal->pt[1].x < pal->pt[2].x ) - end_angle += M_PI; - } + start_angle = atan2(pal->pt[0].y - pal->pt[1].y,pal->pt[1].x - pal->pt[0].x ); + end_angle = atan2(pal->pt[2].y - pal->pt[1].y, pal->pt[1].x - pal->pt[2].x); - if( start_angle >= 2 * M_PI ) - start_angle -= 2 * M_PI; - if( end_angle >= 2 * M_PI ) - end_angle -= 2 * M_PI; if( ( start_angle > end_angle ) && (start_angle - end_angle < M_PI )){ double tmp_angle = start_angle; start_angle = end_angle;