Skip to content

Commit

Permalink
(q)cos -> std::cos
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 24, 2017
1 parent 7c5aa05 commit 2e5d1ab
Show file tree
Hide file tree
Showing 55 changed files with 188 additions and 188 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 * ( ( cos( zenith_rad ) * cos( slope_rad ) ) + ( sin( zenith_rad ) * sin( slope_rad ) * cos( azimuth_rad - aspect_rad ) ) ) );
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 ) ) ) );
}
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsrastermatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ bool QgsRasterMatrix::oneArgumentOperation( OneArgOperator op )
mData[i] = sin( value );
break;
case opCOS:
mData[i] = cos( value );
mData[i] = std::cos( value );
break;
case opTAN:
mData[i] = tan( 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, cos, tan, asin, acos, atan*/
/*sqrt, sin, std::cos, tan, asin, acos, atan*/
bool oneArgumentOperation( OneArgOperator op );
bool testPowerValidity( double base, double power ) const;
};
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsrelief.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ bool QgsRelief::processNineCellWindow( float *x1, float *x2, float *x3, float *x
int r3, g3, b3;
if ( angle_diff < 90 )
{
int aspectVal = ( 1 - cos( angle_diff * M_PI / 180 ) ) * 255;
int aspectVal = ( 1 - std::cos( angle_diff * M_PI / 180 ) ) * 255;
r3 = 0.5 * 255 + hillShadeValue315 * 0.5;
g3 = 0.5 * 255 + hillShadeValue315 * 0.5;
b3 = 0.5 * aspectVal + hillShadeValue315 * 0.5;
Expand Down
6 changes: 3 additions & 3 deletions src/app/dwg/libdxfrw/drw_entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline *pol, int parts ) const
{
double radMajor = sqrt( secPoint.x * secPoint.x + secPoint.y * secPoint.y );
double radMinor = radMajor * ratio;
//calculate sin & cos of included angle
//calculate sin & std::cos of included angle
double incAngle = std::atan2( secPoint.y, secPoint.x );
double cosRot = cos( incAngle );
double cosRot = std::cos( incAngle );
double sinRot = sin( incAngle );

incAngle = M_PIx2 / parts;
Expand All @@ -969,7 +969,7 @@ void DRW_Ellipse::toPolyline( DRW_Polyline *pol, int parts ) const

while ( curAngle < endAngle )
{
double cosCurr = cos( curAngle );
double cosCurr = std::cos( curAngle );
double sinCurr = sin( curAngle );
double x = basePoint.x + cosCurr * cosRot * radMajor - sinCurr * sinRot * radMinor;
double y = basePoint.y + cosCurr * sinRot * radMajor + sinCurr * cosRot * radMinor;
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 + cos( a0 ) * data.mRadius, data.basePoint.y + sin( a0 ) * data.mRadius )
<< QgsPoint( QgsWkbTypes::PointZ, data.basePoint.x + cos( a1 ) * data.mRadius, data.basePoint.y + sin( a1 ) * data.mRadius )
<< QgsPoint( QgsWkbTypes::PointZ, data.basePoint.x + 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 + 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 )
);

if ( !createFeature( layer, f, c ) )
Expand Down Expand Up @@ -1446,7 +1446,7 @@ bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoun
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 h = r * ( 1 - cos( a ) );
double h = r * ( 1 - std::cos( a ) );

s << QgsPoint( QgsWkbTypes::PointZ,
data.vertlist[i0]->x + 0.5 * dx + h * dy / c,
Expand Down Expand Up @@ -1557,7 +1557,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )
double dy = p1.y() - p0.y();
double c = sqrt( dx * dx + dy * dy );
double r = c / 2.0 / sin( a );
double h = r * ( 1 - cos( a ) );
double h = r * ( 1 - std::cos( a ) );

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

s << QgsPoint( QgsWkbTypes::PointZ,
p0.x() + 0.5 * dx + h * dy / c,
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 @@ -682,7 +682,7 @@ QgsPointXY QgsNodeTool::positionForEndpointMarker( const QgsPointLocator::Match
double dy = pt1.y() - pt0.y();
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() + cos( angle ) * dist;
double x = pt1.x() + std::cos( angle ) * dist;
double y = pt1.y() + 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 @@ -137,12 +137,12 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend

double myRadiansDouble = mRotationInt * M_PI / 180.0;
int xShift = static_cast<int>( (
( centerXDouble * cos( myRadiansDouble ) ) +
( centerXDouble * std::cos( myRadiansDouble ) ) +
( centerYDouble * sin( myRadiansDouble ) )
) - centerXDouble );
int yShift = static_cast<int>( (
( -centerXDouble * sin( myRadiansDouble ) ) +
( centerYDouble * cos( myRadiansDouble ) )
( centerYDouble * std::cos( myRadiansDouble ) )
) - centerYDouble );

// need width/height of paint device
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsdecorationnortharrowdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ void QgsDecorationNorthArrowDialog::drawNorthArrow()
const double PI = 3.14159265358979323846;
double myRadiansDouble = ( PI / 180 ) * rotation;
int xShift = static_cast<int>( (
( centerXDouble * cos( myRadiansDouble ) ) +
( centerXDouble * std::cos( myRadiansDouble ) ) +
( centerYDouble * sin( myRadiansDouble ) )
) - centerXDouble );
int yShift = static_cast<int>( (
( -centerXDouble * sin( myRadiansDouble ) ) +
( centerYDouble * cos( myRadiansDouble ) )
( centerYDouble * std::cos( myRadiansDouble ) )
) - centerYDouble );

//draw the pixmap in the proper position
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 * cos( angle ) - ydiff * sin( angle );
double yd = xdiff * sin( angle ) + ydiff * cos( angle );
double xd = xdiff * std::cos( angle ) - ydiff * sin( angle );
double yd = xdiff * 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 = cos( angle ), s = sin( angle );
double c = std::cos( angle ), s = 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 @@ -351,12 +351,12 @@ void QgsMapToolRotateFeature::applyRotation( double rotation )
//calculations for affine transformation
double angle = -1 * mRotation * ( PI / 180 );
QgsPointXY anchorPoint = toLayerCoordinates( vlayer, mStartPointMapCoords );
double a = cos( angle );
double a = std::cos( angle );
double b = -1 * sin( angle );
double c = anchorPoint.x() - cos( angle ) * anchorPoint.x() + sin( angle ) * anchorPoint.y();
double c = anchorPoint.x() - std::cos( angle ) * anchorPoint.x() + sin( angle ) * anchorPoint.y();
double d = sin( angle );
double ee = cos( angle );
double f = anchorPoint.y() - sin( angle ) * anchorPoint.x() - cos( angle ) * anchorPoint.y();
double ee = std::cos( angle );
double f = anchorPoint.y() - 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 = cos( rad ) * v1x - sin( rad ) * v1y;
double v2y = sin( rad ) * v1x + cos( rad ) * v1y;
double v2x = std::cos( rad ) * v1x - sin( rad ) * v1y;
double v2y = 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 @@ -107,7 +107,7 @@ void QgsMapToolSelectRadius::setRadiusRubberBand( QgsPointXY &radiusEdge )
for ( int i = 0; i <= RADIUS_SEGMENTS; ++i )
{
double theta = i * ( 2.0 * M_PI / RADIUS_SEGMENTS );
QgsPointXY radiusPoint( mRadiusCenter.x() + r * cos( theta ),
QgsPointXY radiusPoint( mRadiusCenter.x() + r * std::cos( theta ),
mRadiusCenter.y() + r * sin( theta ) );
mRubberBand->addPoint( radiusPoint, false );
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgspointrotationitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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 * cos( ( painterRotation( mRotation ) - dAngel ) * M_PI / 180 );
x = h * std::cos( ( painterRotation( mRotation ) - dAngel ) * M_PI / 180 );
y = h * sin( ( painterRotation( mRotation ) - dAngel ) * M_PI / 180 );
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsrastercalcdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void QgsRasterCalcDialog::on_mSqrtButton_clicked()

void QgsRasterCalcDialog::on_mCosButton_clicked()
{
mExpressionTextEdit->insertPlainText( QStringLiteral( " cos ( " ) );
mExpressionTextEdit->insertPlainText( QStringLiteral( " std::cos ( " ) );
}

void QgsRasterCalcDialog::on_mSinButton_clicked()
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposerarrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ void QgsComposerArrow::drawSVGMarker( QPainter *p, MarkerType type, const QStrin
}
QPointF rotatedFixPoint;
double angleRad = angle / 180 * M_PI;
rotatedFixPoint.setX( fixPoint.x() * cos( angleRad ) + fixPoint.y() * -sin( angleRad ) );
rotatedFixPoint.setY( fixPoint.x() * sin( angleRad ) + fixPoint.y() * cos( angleRad ) );
rotatedFixPoint.setX( fixPoint.x() * std::cos( angleRad ) + fixPoint.y() * -sin( angleRad ) );
rotatedFixPoint.setY( fixPoint.x() * sin( angleRad ) + fixPoint.y() * std::cos( angleRad ) );
p->translate( canvasPoint.x() - rotatedFixPoint.x(), canvasPoint.y() - rotatedFixPoint.y() );
}
else
Expand Down
14 changes: 7 additions & 7 deletions src/core/composer/qgscomposerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ void QgsComposerUtils::drawArrowHead( QPainter *p, const double x, const double
QPointF p2 = QPointF( arrowHeadWidth / 2.0, arrowHeadWidth );

QPointF p1Rotated, p2Rotated;
p1Rotated.setX( p1.x() * cos( angleRad ) + p1.y() * -sin( angleRad ) );
p1Rotated.setY( p1.x() * sin( angleRad ) + p1.y() * cos( angleRad ) );
p2Rotated.setX( p2.x() * cos( angleRad ) + p2.y() * -sin( angleRad ) );
p2Rotated.setY( p2.x() * sin( angleRad ) + p2.y() * cos( angleRad ) );
p1Rotated.setX( p1.x() * std::cos( angleRad ) + p1.y() * -sin( angleRad ) );
p1Rotated.setY( p1.x() * 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 ) );

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 * cos( rotToRad ) - y * sin( rotToRad );
yRot = x * sin( rotToRad ) + y * cos( rotToRad );
xRot = x * std::cos( rotToRad ) - y * sin( rotToRad );
yRot = x * sin( rotToRad ) + y * std::cos( rotToRad );
x = xRot;
y = yRot;
}
Expand Down Expand Up @@ -185,7 +185,7 @@ QRectF QgsComposerUtils::largestRotatedRectWithinBounds( const QRectF &originalR

//convert angle to radians and flip
double angleRad = -clippedRotation * M_DEG2RAD;
double cosAngle = cos( angleRad );
double cosAngle = std::cos( angleRad );
double sinAngle = sin( angleRad );

//calculate size of bounds of rotated rectangle
Expand Down
10 changes: 5 additions & 5 deletions src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3012,7 +3012,7 @@ double *QgsComposition::computeGeoTransform( const QgsComposerMap *map, const QR
double mapYCenter = mapExtent.center().y();
double alpha = - map->mapRotation() / 180 * M_PI;
double sinAlpha = sin( alpha );
double cosAlpha = cos( alpha );
double cosAlpha = std::cos( alpha );

// get the extent (in map units) for the exported region
QPointF mapItemPos = map->pos();
Expand Down Expand Up @@ -3151,12 +3151,12 @@ void QgsComposition::computeWorldFileParameters( const QRectF &exportRegion, dou

// rotation matrix
double r[6];
r[0] = cos( alpha );
r[0] = std::cos( alpha );
r[1] = -sin( alpha );
r[2] = xCenter * ( 1 - cos( alpha ) ) + yCenter * sin( alpha );
r[2] = xCenter * ( 1 - std::cos( alpha ) ) + yCenter * sin( alpha );
r[3] = sin( alpha );
r[4] = cos( alpha );
r[5] = - xCenter * sin( alpha ) + yCenter * ( 1 - cos( alpha ) );
r[4] = std::cos( alpha );
r[5] = - xCenter * 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 @@ -56,7 +56,7 @@ void QgsShadowEffect::draw( QgsRenderContext &context )
double offsetDist = context.convertToPainterUnits( mOffsetDist, mOffsetUnit, mOffsetMapUnitScale );

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

//transparency, scale
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 @@ -262,7 +262,7 @@ static QVariant fcnSin( const QVariantList &values, const QgsExpressionContext *
static QVariant fcnCos( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent )
{
double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
return QVariant( cos( x ) );
return QVariant( std::cos( x ) );
}
static QVariant fcnTan( 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 @@ -208,11 +208,11 @@ QgsPointSequence QgsEllipse::points( unsigned int segments ) const
for ( QVector<double>::const_iterator it = t.constBegin(); it != t.constEnd(); ++it )
{
double x = mCenter.x() +
mSemiMajorAxis * cos( *it ) * cos( azimuth ) -
mSemiMajorAxis * std::cos( *it ) * std::cos( azimuth ) -
mSemiMinorAxis * sin( *it ) * sin( azimuth );
double y = mCenter.y() +
mSemiMajorAxis * cos( *it ) * sin( azimuth ) +
mSemiMinorAxis * sin( *it ) * cos( azimuth );
mSemiMajorAxis * std::cos( *it ) * sin( azimuth ) +
mSemiMinorAxis * sin( *it ) * std::cos( azimuth );
pts.push_back( QgsPoint( pType, x, y, z, m ) );
}

Expand Down Expand Up @@ -257,10 +257,10 @@ QgsRectangle QgsEllipse::boundingBox() const

double angle = mAzimuth * M_PI / 180.0;

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

double halfHeight = sqrt( ux * ux + uy * uy );
double halfWidth = sqrt( vx * vx + vy * vy );
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 @@ -703,7 +703,7 @@ void QgsGeometryUtils::segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, co
addP2 = false;
}

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

if ( !hasZ && !hasM )
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsinternalgeometryengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ QgsGeometry QgsInternalGeometryEngine::orthogonalize( double tolerance, int maxI
return QgsGeometry();
}

double lowerThreshold = cos( ( 90 - angleThreshold ) * M_PI / 180.00 );
double upperThreshold = cos( angleThreshold * M_PI / 180.0 );
double lowerThreshold = std::cos( ( 90 - angleThreshold ) * M_PI / 180.00 );
double upperThreshold = std::cos( angleThreshold * M_PI / 180.0 );

if ( const QgsGeometryCollection *gc = qgsgeometry_cast< const QgsGeometryCollection *>( mGeometry ) )
{
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 @@ -567,14 +567,14 @@ QgsPoint QgsPoint::project( double distance, double azimuth, double inclination
if ( !is3D() && qgsDoubleNear( inclination, 90.0 ) )
{
dx = distance * sin( radsXy );
dy = distance * cos( radsXy );
dy = distance * std::cos( radsXy );
}
else
{
double radsZ = inclination * M_PI / 180.0;
dx = distance * sin( radsZ ) * sin( radsXy );
dy = distance * sin( radsZ ) * cos( radsXy );
dz = distance * cos( radsZ );
dy = distance * sin( radsZ ) * std::cos( radsXy );
dz = distance * std::cos( radsZ );
}

return QgsPoint( mX + dx, mY + dy, mZ + dz, mM, pType );
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 @@ -113,7 +113,7 @@ QgsRegularPolygon::QgsRegularPolygon( const QgsPoint &pt1, const QgsPoint &pt2,
double length = pt1.distance( pm );

double angle = ( 180 - ( 360 / numSides ) ) / 2.0;
double hypothenuse = length / cos( angle * M_PI / 180 );
double hypothenuse = length / std::cos( angle * M_PI / 180 );
// TODO: inclination

mCenter = pt1.project( hypothenuse, azimuth + angle );
Expand Down Expand Up @@ -327,7 +327,7 @@ double QgsRegularPolygon::length() const

double QgsRegularPolygon::apothemToRadius( const double apothem, const unsigned int numSides ) const
{
return apothem / cos( M_PI / numSides );
return apothem / std::cos( M_PI / numSides );
}

double QgsRegularPolygon::interiorAngle( const unsigned int nbSides ) const
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsregularpolygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class CORE_EXPORT QgsRegularPolygon
* The apothem is the radius of the inscribed circle.
* \see radius()
*/
double apothem() const { return mRadius * cos( M_PI / mNumberSides ); }
double apothem() const { return mRadius * std::cos( M_PI / mNumberSides ); }

/** Returns the number of sides of the regular polygon.
* \see setNumberSides()
Expand Down