tdf#147906 change sqrt(a * a + b * b) occurences to std::hypot(a, b)

Change-Id: Ic84899bf34f98382e6cc1ffc14310b1667279ee2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132214
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Bartosz Kosiorek
2022-03-29 09:17:42 +02:00
committed by Mike Kaganski
parent 4cdb50923e
commit a2d49b680c
4 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ void Impl_calcFatLine( FatLine& line, const Bezier& c )
line.b = (c.p0.x - c.p3.x);
// normalize
const double len( sqrt( line.a*line.a + line.b*line.b ) );
const double len(std::hypot(line.a, line.b));
if( !tolZero(len) )
{
line.a /= len;
+3 -5
View File
@@ -512,8 +512,7 @@ void PieChart::createTextLabelShape(
{
//when the line is very short compared to the page size don't create one
::basegfx::B2DVector aLength(nX1 - nX2, nY1 - nY2);
double fPageDiagonaleLength = sqrt(double(nPageWidth) * double(nPageWidth)
+ double(nPageHeight) * double(nPageHeight));
double fPageDiagonaleLength = std::hypot(nPageWidth, nPageHeight);
if ((aLength.getLength() / fPageDiagonaleLength) >= 0.01)
{
drawing::PointSequenceSequence aPoints{ { {nX1, nY1}, {nX2, nY2} } };
@@ -1235,7 +1234,7 @@ void PieChart::rearrangeLabelToAvoidOverlapIfRequested( const awt::Size& rPageSi
if(!bMoveableFound)
return;
double fPageDiagonaleLength = sqrt( double(rPageSize.Width)*double(rPageSize.Width) + double(rPageSize.Height)*double(rPageSize.Height) );
double fPageDiagonaleLength = std::hypot(rPageSize.Width, rPageSize.Height);
if( fPageDiagonaleLength == 0.0 )
return;
@@ -1475,8 +1474,7 @@ bool PieChart::performLabelBestFitInnerPlacement(ShapeParam& rShapeParam, PieLab
// compute the length of the diagonal vector d,
// that is the distance between P and F
double fSquaredDistancePF = fDistancePM * fDistancePM + fOrthogonalEdgeLength * fOrthogonalEdgeLength;
double fDistancePF = sqrt( fSquaredDistancePF );
double fDistancePF = std::hypot(fDistancePM, fOrthogonalEdgeLength);
SAL_INFO( "chart2.pie.label.bestfit.inside",
" width = " << fLabelWidth );
@@ -720,7 +720,8 @@ rtl::Reference<SvxShapeText> VSeriesPlotter::createDataLabel( const rtl::Referen
//when the line is very short compared to the page size don't create one
::basegfx::B2DVector aLength(nX1 - nX2, nY1 - nY2);
double fPageDiagonaleLength = sqrt(double(m_aPageReferenceSize.Width)*double(m_aPageReferenceSize.Width) + double(m_aPageReferenceSize.Height)*double(m_aPageReferenceSize.Height));
double fPageDiagonaleLength
= std::hypot(m_aPageReferenceSize.Width, m_aPageReferenceSize.Height);
if ((aLength.getLength() / fPageDiagonaleLength) >= 0.01)
{
drawing::PointSequenceSequence aPoints{ { {nX1, nY1}, {nX2, nY2} } };
+1 -1
View File
@@ -1740,7 +1740,7 @@ namespace emfio
double fY = aP2.Y();
if ( fX )
{
double fOrientation = basegfx::rad2deg( acos( fX / sqrt( fX * fX + fY * fY ) ) );
double fOrientation = basegfx::rad2deg(acos(fX / std::hypot(fX, fY)));
if ( fY > 0 )
fOrientation = 360 - fOrientation;
fOrientation += 90;