Skip to content

Commit

Permalink
(q)sin -> std::sin
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 24, 2017
1 parent 8c64d80 commit fec03ca
Show file tree
Hide file tree
Showing 51 changed files with 169 additions and 169 deletions.
2 changes: 1 addition & 1 deletion src/analysis/raster/qgshillshadefilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) ) );
}
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsrastermatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsrastermatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions src/app/dwg/libdxfrw/drw_entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 ) );
Expand Down
12 changes: 6 additions & 6 deletions src/app/dwg/qgsdwgimporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/app/nodetool/qgsnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsdecorationnortharrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsdecorationnortharrowdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoollabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptooloffsetpointsymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

8 changes: 4 additions & 4 deletions src/app/qgsmaptoolrotatefeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) );

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolrotatelabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolselectradius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgspointrotationitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerarrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/core/composer/qgscomposerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 );
Expand Down
8 changes: 4 additions & 4 deletions src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/core/effects/qgsshadoweffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/core/expression/qgsexpressionfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
10 changes: 5 additions & 5 deletions src/core/geometry/qgsellipse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometryutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
6 changes: 3 additions & 3 deletions src/core/geometry/qgspoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsregularpolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit fec03ca

Please sign in to comment.