Skip to content
Permalink
Browse files

(q)sin -> std::sin

  • Loading branch information
nyalldawson committed Aug 24, 2017
1 parent 8c64d80 commit fec03ca42300d67b84e520a569cd34f5f4885746
Showing with 169 additions and 169 deletions.
  1. +1 −1 src/analysis/raster/qgshillshadefilter.cpp
  2. +1 −1 src/analysis/raster/qgsrastermatrix.cpp
  3. +1 −1 src/analysis/raster/qgsrastermatrix.h
  4. +2 −2 src/app/dwg/libdxfrw/drw_entities.cpp
  5. +6 −6 src/app/dwg/qgsdwgimporter.cpp
  6. +1 −1 src/app/nodetool/qgsnodetool.cpp
  7. +2 −2 src/app/qgsdecorationnortharrow.cpp
  8. +2 −2 src/app/qgsdecorationnortharrowdialog.cpp
  9. +2 −2 src/app/qgsmaptoollabel.cpp
  10. +1 −1 src/app/qgsmaptooloffsetpointsymbol.cpp
  11. +4 −4 src/app/qgsmaptoolrotatefeature.cpp
  12. +2 −2 src/app/qgsmaptoolrotatelabel.cpp
  13. +1 −1 src/app/qgsmaptoolselectradius.cpp
  14. +1 −1 src/app/qgspointrotationitem.cpp
  15. +1 −1 src/core/composer/qgscomposerarrow.cpp
  16. +5 −5 src/core/composer/qgscomposerutils.cpp
  17. +4 −4 src/core/composer/qgscomposition.cpp
  18. +1 −1 src/core/effects/qgsshadoweffect.cpp
  19. +1 −1 src/core/expression/qgsexpressionfunction.cpp
  20. +5 −5 src/core/geometry/qgsellipse.cpp
  21. +1 −1 src/core/geometry/qgsgeometryutils.cpp
  22. +3 −3 src/core/geometry/qgspoint.cpp
  23. +2 −2 src/core/geometry/qgsregularpolygon.cpp
  24. +25 −25 src/core/pal/feature.cpp
  25. +2 −2 src/core/pal/geomfunction.cpp
  26. +2 −2 src/core/pal/labelposition.cpp
  27. +2 −2 src/core/pal/pointset.cpp
  28. +12 −12 src/core/qgsdistancearea.cpp
  29. +3 −3 src/core/qgsmapsettingsutils.cpp
  30. +2 −2 src/core/qgspallabeling.cpp
  31. +1 −1 src/core/qgspointxy.cpp
  32. +1 −1 src/core/qgsscalecalculator.cpp
  33. +3 −3 src/core/qgstextrenderer.cpp
  34. +1 −1 src/core/qgsvector.cpp
  35. +2 −2 src/core/qgsvectorlayerlabelprovider.cpp
  36. +7 −7 src/core/raster/qgshillshaderenderer.cpp
  37. +5 −5 src/core/symbology/qgs25drenderer.cpp
  38. +1 −1 src/core/symbology/qgsarrowsymbollayer.cpp
  39. +1 −1 src/core/symbology/qgsellipsesymbollayer.cpp
  40. +6 −6 src/core/symbology/qgsfillsymbollayer.cpp
  41. +2 −2 src/core/symbology/qgslinesymbollayer.cpp
  42. +20 −20 src/core/symbology/qgsmarkersymbollayer.cpp
  43. +2 −2 src/core/symbology/qgspointdisplacementrenderer.cpp
  44. +1 −1 src/core/symbology/qgssymbollayer.cpp
  45. +1 −1 src/core/symbology/qgsvectorfieldsymbollayer.cpp
  46. +3 −3 src/gui/qgsadvanceddigitizingcanvasitem.cpp
  47. +2 −2 src/gui/qgsadvanceddigitizingdockwidget.cpp
  48. +3 −3 src/gui/qgscolorwidgets.cpp
  49. +2 −2 src/plugins/georeferencer/qgsgeorefplugingui.cpp
  50. +5 −5 src/plugins/georeferencer/qgsgeoreftransform.cpp
  51. +2 −2 tests/src/core/testqgsgeometry.cpp
@@ -49,5 +49,5 @@ float QgsHillshadeFilter::processNineCellWindow( float *x11, float *x21, float *
{
aspect_rad = M_PI + std::atan2( derX, derY );
}
return qMax( 0.0, 255.0 * ( ( std::cos( zenith_rad ) * std::cos( slope_rad ) ) + ( sin( zenith_rad ) * sin( slope_rad ) * std::cos( azimuth_rad - aspect_rad ) ) ) );
return qMax( 0.0, 255.0 * ( ( std::cos( zenith_rad ) * std::cos( slope_rad ) ) + ( std::sin( zenith_rad ) * std::sin( slope_rad ) * std::cos( azimuth_rad - aspect_rad ) ) ) );
}
@@ -220,7 +220,7 @@ bool QgsRasterMatrix::oneArgumentOperation( OneArgOperator op )
}
break;
case opSIN:
mData[i] = sin( value );
mData[i] = std::sin( value );
break;
case opCOS:
mData[i] = std::cos( value );
@@ -124,7 +124,7 @@ class ANALYSIS_EXPORT QgsRasterMatrix
bool twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix &other );
double calculateTwoArgumentOp( TwoArgOperator op, double arg1, double arg2 ) const;

/*sqrt, sin, std::cos, tan, asin, acos, atan*/
/*sqrt, std::sin, std::cos, tan, asin, acos, atan*/
bool oneArgumentOperation( OneArgOperator op );
bool testPowerValidity( double base, double power ) const;
};
@@ -959,7 +959,7 @@ void DRW_Ellipse::toPolyline( DRW_Polyline *pol, int parts ) const
//calculate sin & std::cos of included angle
double incAngle = std::atan2( secPoint.y, secPoint.x );
double cosRot = std::cos( incAngle );
double sinRot = sin( incAngle );
double sinRot = std::sin( incAngle );

incAngle = M_PIx2 / parts;
double curAngle = staparam;
@@ -970,7 +970,7 @@ void DRW_Ellipse::toPolyline( DRW_Polyline *pol, int parts ) const
while ( curAngle < endAngle )
{
double cosCurr = std::cos( curAngle );
double sinCurr = sin( curAngle );
double sinCurr = std::sin( curAngle );
double x = basePoint.x + cosCurr * cosRot * radMajor - sinCurr * sinRot * radMinor;
double y = basePoint.y + cosCurr * sinRot * radMajor + sinCurr * cosRot * radMinor;
pol->addVertex( DRW_Vertex( x, y, 0.0, 0.0 ) );
@@ -1341,9 +1341,9 @@ void QgsDwgImporter::addArc( const DRW_Arc &data )

QgsCircularString c;
c.setPoints( QgsPointSequence()
<< QgsPoint( QgsWkbTypes::PointZ, data.basePoint.x + std::cos( a0 ) * data.mRadius, data.basePoint.y + sin( a0 ) * data.mRadius )
<< QgsPoint( QgsWkbTypes::PointZ, data.basePoint.x + std::cos( a1 ) * data.mRadius, data.basePoint.y + sin( a1 ) * data.mRadius )
<< QgsPoint( QgsWkbTypes::PointZ, data.basePoint.x + std::cos( a2 ) * data.mRadius, data.basePoint.y + sin( a2 ) * data.mRadius )
<< QgsPoint( QgsWkbTypes::PointZ, data.basePoint.x + std::cos( a0 ) * data.mRadius, data.basePoint.y + std::sin( a0 ) * data.mRadius )
<< QgsPoint( QgsWkbTypes::PointZ, data.basePoint.x + std::cos( a1 ) * data.mRadius, data.basePoint.y + std::sin( a1 ) * data.mRadius )
<< QgsPoint( QgsWkbTypes::PointZ, data.basePoint.x + std::cos( a2 ) * data.mRadius, data.basePoint.y + std::sin( a2 ) * data.mRadius )
);

if ( !createFeature( layer, f, c ) )
@@ -1445,7 +1445,7 @@ bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoun
double dx = data.vertlist[i1]->x - data.vertlist[i0]->x;
double dy = data.vertlist[i1]->y - data.vertlist[i0]->y;
double c = sqrt( dx * dx + dy * dy );
double r = c / 2.0 / sin( a );
double r = c / 2.0 / std::sin( a );
double h = r * ( 1 - std::cos( a ) );

s << QgsPoint( QgsWkbTypes::PointZ,
@@ -1556,7 +1556,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )
double dx = p1.x() - p0.x();
double dy = p1.y() - p0.y();
double c = sqrt( dx * dx + dy * dy );
double r = c / 2.0 / sin( a );
double r = c / 2.0 / std::sin( a );
double h = r * ( 1 - std::cos( a ) );

s << QgsPoint( QgsWkbTypes::PointZ,
@@ -1758,7 +1758,7 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data )
double dy = p1.y() - p0.y();
double dz = p1.z() - p0.z();
double c = sqrt( dx * dx + dy * dy );
double r = c / 2.0 / sin( a );
double r = c / 2.0 / std::sin( a );
double h = r * ( 1 - std::cos( a ) );

s << QgsPoint( QgsWkbTypes::PointZ,
@@ -683,7 +683,7 @@ QgsPointXY QgsNodeTool::positionForEndpointMarker( const QgsPointLocator::Match
double dist = 15 * canvas()->mapSettings().mapUnitsPerPixel();
double angle = std::atan2( dy, dx ); // to the top: angle=0, to the right: angle=90, to the left: angle=-90
double x = pt1.x() + std::cos( angle ) * dist;
double y = pt1.y() + sin( angle ) * dist;
double y = pt1.y() + std::sin( angle ) * dist;
return QgsPointXY( x, y );
}

@@ -138,10 +138,10 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend
double myRadiansDouble = mRotationInt * M_PI / 180.0;
int xShift = static_cast<int>( (
( centerXDouble * std::cos( myRadiansDouble ) ) +
( centerYDouble * sin( myRadiansDouble ) )
( centerYDouble * std::sin( myRadiansDouble ) )
) - centerXDouble );
int yShift = static_cast<int>( (
( -centerXDouble * sin( myRadiansDouble ) ) +
( -centerXDouble * std::sin( myRadiansDouble ) ) +
( centerYDouble * std::cos( myRadiansDouble ) )
) - centerYDouble );

@@ -156,10 +156,10 @@ void QgsDecorationNorthArrowDialog::drawNorthArrow()
double myRadiansDouble = ( PI / 180 ) * rotation;
int xShift = static_cast<int>( (
( centerXDouble * std::cos( myRadiansDouble ) ) +
( centerYDouble * sin( myRadiansDouble ) )
( centerYDouble * std::sin( myRadiansDouble ) )
) - centerXDouble );
int yShift = static_cast<int>( (
( -centerXDouble * sin( myRadiansDouble ) ) +
( -centerXDouble * std::sin( myRadiansDouble ) ) +
( centerYDouble * std::cos( myRadiansDouble ) )
) - centerYDouble );

@@ -376,8 +376,8 @@ bool QgsMapToolLabel::currentLabelRotationPoint( QgsPointXY &pos, bool ignoreUps
}

double angle = mCurrentLabel.pos.rotation;
double xd = xdiff * std::cos( angle ) - ydiff * sin( angle );
double yd = xdiff * sin( angle ) + ydiff * std::cos( angle );
double xd = xdiff * std::cos( angle ) - ydiff * std::sin( angle );
double yd = xdiff * std::sin( angle ) + ydiff * std::cos( angle );
if ( mCurrentLabel.pos.upsideDown && !ignoreUpsideDown )
{
pos.setX( pos.x() - xd );
@@ -270,7 +270,7 @@ QPointF QgsMapToolOffsetPointSymbol::calculateOffset( const QgsPointXY &startPoi
QPointF QgsMapToolOffsetPointSymbol::rotatedOffset( QPointF offset, double angle ) const
{
angle = DEG2RAD( 360 - angle );
double c = std::cos( angle ), s = sin( angle );
double c = std::cos( angle ), s = std::sin( angle );
return QPointF( offset.x() * c - offset.y() * s, offset.x() * s + offset.y() * c );
}

@@ -352,11 +352,11 @@ void QgsMapToolRotateFeature::applyRotation( double rotation )
double angle = -1 * mRotation * ( PI / 180 );
QgsPointXY anchorPoint = toLayerCoordinates( vlayer, mStartPointMapCoords );
double a = std::cos( angle );
double b = -1 * sin( angle );
double c = anchorPoint.x() - std::cos( angle ) * anchorPoint.x() + sin( angle ) * anchorPoint.y();
double d = sin( angle );
double b = -1 * std::sin( angle );
double c = anchorPoint.x() - std::cos( angle ) * anchorPoint.x() + std::sin( angle ) * anchorPoint.y();
double d = std::sin( angle );
double ee = std::cos( angle );
double f = anchorPoint.y() - sin( angle ) * anchorPoint.x() - std::cos( angle ) * anchorPoint.y();
double f = anchorPoint.y() - std::sin( angle ) * anchorPoint.x() - std::cos( angle ) * anchorPoint.y();

vlayer->beginEditCommand( tr( "Features Rotated" ) );

@@ -230,8 +230,8 @@ QgsPointXY QgsMapToolRotateLabel::rotatePointCounterClockwise( const QgsPointXY
double v1x = input.x() - centerPoint.x();
double v1y = input.y() - centerPoint.y();

double v2x = std::cos( rad ) * v1x - sin( rad ) * v1y;
double v2y = sin( rad ) * v1x + std::cos( rad ) * v1y;
double v2x = std::cos( rad ) * v1x - std::sin( rad ) * v1y;
double v2y = std::sin( rad ) * v1x + std::cos( rad ) * v1y;

return QgsPointXY( centerPoint.x() + v2x, centerPoint.y() + v2y );
}
@@ -108,7 +108,7 @@ void QgsMapToolSelectRadius::setRadiusRubberBand( QgsPointXY &radiusEdge )
{
double theta = i * ( 2.0 * M_PI / RADIUS_SEGMENTS );
QgsPointXY radiusPoint( mRadiusCenter.x() + r * std::cos( theta ),
mRadiusCenter.y() + r * sin( theta ) );
mRadiusCenter.y() + r * std::sin( theta ) );
mRubberBand->addPoint( radiusPoint, false );
}
mRubberBand->closePoints( true );
@@ -57,7 +57,7 @@ void QgsPointRotationItem::paint( QPainter *painter )
h = sqrt( ( double ) mPixmap.width() * mPixmap.width() + mPixmap.height() * mPixmap.height() ) / 2; //the half of the item diagonal
dAngel = acos( mPixmap.width() / ( h * 2 ) ) * 180 / M_PI; //the diagonal angel of the original rect
x = h * std::cos( ( painterRotation( mRotation ) - dAngel ) * M_PI / 180 );
y = h * sin( ( painterRotation( mRotation ) - dAngel ) * M_PI / 180 );
y = h * std::sin( ( painterRotation( mRotation ) - dAngel ) * M_PI / 180 );
}

painter->rotate( painterRotation( mRotation ) );
@@ -281,7 +281,7 @@ void QgsComposerArrow::drawSVGMarker( QPainter *p, MarkerType type, const QStrin
QPointF rotatedFixPoint;
double angleRad = angle / 180 * M_PI;
rotatedFixPoint.setX( fixPoint.x() * std::cos( angleRad ) + fixPoint.y() * -sin( angleRad ) );
rotatedFixPoint.setY( fixPoint.x() * sin( angleRad ) + fixPoint.y() * std::cos( angleRad ) );
rotatedFixPoint.setY( fixPoint.x() * std::sin( angleRad ) + fixPoint.y() * std::cos( angleRad ) );
p->translate( canvasPoint.x() - rotatedFixPoint.x(), canvasPoint.y() - rotatedFixPoint.y() );
}
else
@@ -43,9 +43,9 @@ void QgsComposerUtils::drawArrowHead( QPainter *p, const double x, const double

QPointF p1Rotated, p2Rotated;
p1Rotated.setX( p1.x() * std::cos( angleRad ) + p1.y() * -sin( angleRad ) );
p1Rotated.setY( p1.x() * sin( angleRad ) + p1.y() * std::cos( angleRad ) );
p1Rotated.setY( p1.x() * std::sin( angleRad ) + p1.y() * std::cos( angleRad ) );
p2Rotated.setX( p2.x() * std::cos( angleRad ) + p2.y() * -sin( angleRad ) );
p2Rotated.setY( p2.x() * sin( angleRad ) + p2.y() * std::cos( angleRad ) );
p2Rotated.setY( p2.x() * std::sin( angleRad ) + p2.y() * std::cos( angleRad ) );

QPolygonF arrowHeadPoly;
arrowHeadPoly << middlePoint;
@@ -88,8 +88,8 @@ void QgsComposerUtils::rotate( const double angle, double &x, double &y )
{
double rotToRad = angle * M_PI / 180.0;
double xRot, yRot;
xRot = x * std::cos( rotToRad ) - y * sin( rotToRad );
yRot = x * sin( rotToRad ) + y * std::cos( rotToRad );
xRot = x * std::cos( rotToRad ) - y * std::sin( rotToRad );
yRot = x * std::sin( rotToRad ) + y * std::cos( rotToRad );
x = xRot;
y = yRot;
}
@@ -186,7 +186,7 @@ QRectF QgsComposerUtils::largestRotatedRectWithinBounds( const QRectF &originalR
//convert angle to radians and flip
double angleRad = -clippedRotation * M_DEG2RAD;
double cosAngle = std::cos( angleRad );
double sinAngle = sin( angleRad );
double sinAngle = std::sin( angleRad );

//calculate size of bounds of rotated rectangle
double widthBoundsRotatedRect = originalWidth * std::fabs( cosAngle ) + originalHeight * std::fabs( sinAngle );
@@ -3011,7 +3011,7 @@ double *QgsComposition::computeGeoTransform( const QgsComposerMap *map, const QR
double mapXCenter = mapExtent.center().x();
double mapYCenter = mapExtent.center().y();
double alpha = - map->mapRotation() / 180 * M_PI;
double sinAlpha = sin( alpha );
double sinAlpha = std::sin( alpha );
double cosAlpha = std::cos( alpha );

// get the extent (in map units) for the exported region
@@ -3153,10 +3153,10 @@ void QgsComposition::computeWorldFileParameters( const QRectF &exportRegion, dou
double r[6];
r[0] = std::cos( alpha );
r[1] = -sin( alpha );
r[2] = xCenter * ( 1 - std::cos( alpha ) ) + yCenter * sin( alpha );
r[3] = sin( alpha );
r[2] = xCenter * ( 1 - std::cos( alpha ) ) + yCenter * std::sin( alpha );
r[3] = std::sin( alpha );
r[4] = std::cos( alpha );
r[5] = - xCenter * sin( alpha ) + yCenter * ( 1 - std::cos( alpha ) );
r[5] = - xCenter * std::sin( alpha ) + yCenter * ( 1 - std::cos( alpha ) );

// result = rotation x scaling = rotation(scaling(X))
a = r[0] * s[0] + r[1] * s[3];
@@ -57,7 +57,7 @@ void QgsShadowEffect::draw( QgsRenderContext &context )

double angleRad = mOffsetAngle * M_PI / 180; // to radians
QPointF transPt( -offsetDist * std::cos( angleRad + M_PI / 2 ),
-offsetDist * sin( angleRad + M_PI / 2 ) );
-offsetDist * std::sin( angleRad + M_PI / 2 ) );

//transparency, scale
QgsImageOperation::multiplyOpacity( colorisedIm, mOpacity );
@@ -257,7 +257,7 @@ static QVariant fcnDegrees( const QVariantList &values, const QgsExpressionConte
static QVariant fcnSin( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent )
{
double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
return QVariant( sin( x ) );
return QVariant( std::sin( x ) );
}
static QVariant fcnCos( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent )
{
@@ -209,10 +209,10 @@ QgsPointSequence QgsEllipse::points( unsigned int segments ) const
{
double x = mCenter.x() +
mSemiMajorAxis * std::cos( *it ) * std::cos( azimuth ) -
mSemiMinorAxis * sin( *it ) * sin( azimuth );
mSemiMinorAxis * std::sin( *it ) * std::sin( azimuth );
double y = mCenter.y() +
mSemiMajorAxis * std::cos( *it ) * sin( azimuth ) +
mSemiMinorAxis * sin( *it ) * std::cos( azimuth );
mSemiMajorAxis * std::cos( *it ) * std::sin( azimuth ) +
mSemiMinorAxis * std::sin( *it ) * std::cos( azimuth );
pts.push_back( QgsPoint( pType, x, y, z, m ) );
}

@@ -258,8 +258,8 @@ QgsRectangle QgsEllipse::boundingBox() const
double angle = mAzimuth * M_PI / 180.0;

double ux = mSemiMajorAxis * std::cos( angle );
double uy = mSemiMinorAxis * sin( angle );
double vx = mSemiMajorAxis * sin( angle );
double uy = mSemiMinorAxis * std::sin( angle );
double vx = mSemiMajorAxis * std::sin( angle );
double vy = mSemiMinorAxis * std::cos( angle );

double halfHeight = sqrt( ux * ux + uy * uy );
@@ -704,7 +704,7 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
}

x = centerX + radius * std::cos( angle );
y = centerY + radius * sin( angle );
y = centerY + radius * std::sin( angle );

if ( !hasZ && !hasM )
{
@@ -566,14 +566,14 @@ QgsPoint QgsPoint::project( double distance, double azimuth, double inclination

if ( !is3D() && qgsDoubleNear( inclination, 90.0 ) )
{
dx = distance * sin( radsXy );
dx = distance * std::sin( radsXy );
dy = distance * std::cos( radsXy );
}
else
{
double radsZ = inclination * M_PI / 180.0;
dx = distance * sin( radsZ ) * sin( radsXy );
dy = distance * sin( radsZ ) * std::cos( radsXy );
dx = distance * std::sin( radsZ ) * std::sin( radsXy );
dy = distance * std::sin( radsZ ) * std::cos( radsXy );
dz = distance * std::cos( radsZ );
}

@@ -302,7 +302,7 @@ double QgsRegularPolygon::area() const
return 0.0;
}

return ( mRadius * mRadius * mNumberSides * sin( centralAngle() * M_PI / 180.0 ) ) / 2 ;
return ( mRadius * mRadius * mNumberSides * std::sin( centralAngle() * M_PI / 180.0 ) ) / 2 ;
}

double QgsRegularPolygon::perimeter() const
@@ -322,7 +322,7 @@ double QgsRegularPolygon::length() const
return 0.0;
}

return mRadius * 2 * sin( M_PI / mNumberSides );
return mRadius * 2 * std::sin( M_PI / mNumberSides );
}

double QgsRegularPolygon::apothemToRadius( const double apothem, const unsigned int numSides ) const

0 comments on commit fec03ca

Please sign in to comment.
You can’t perform that action at this time.