Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove redundant math constant defines
Since we use _USE_MATH_DEFINES for windows builds, these are
not required
  • Loading branch information
nyalldawson committed Aug 25, 2017
1 parent 07a570f commit 7f44737
Show file tree
Hide file tree
Showing 15 changed files with 5 additions and 65 deletions.
1 change: 0 additions & 1 deletion python/core/symbology/qgssymbollayer.sip
Expand Up @@ -11,7 +11,6 @@




class QgsSymbolLayer
{

Expand Down
4 changes: 0 additions & 4 deletions src/analysis/raster/qgskde.cpp
Expand Up @@ -20,10 +20,6 @@

#define NO_DATA -9999

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

QgsKernelDensityEstimation::QgsKernelDensityEstimation( const QgsKernelDensityEstimation::Parameters &parameters, const QString &outputFile, const QString &outputFormat )
: mSource( parameters.source )
, mOutputFile( outputFile )
Expand Down
6 changes: 0 additions & 6 deletions src/app/dwg/libdxfrw/drw_base.h
Expand Up @@ -38,12 +38,6 @@
# define DRW_POSIX
#endif

#ifndef M_PI
#define M_PI 3.141592653589793238462643
#endif
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif
#define M_PIx2 6.283185307179586 // 2*PI
#define ARAD 57.29577951308232

Expand Down
3 changes: 1 addition & 2 deletions src/app/qgsdecorationnortharrowdialog.cpp
Expand Up @@ -152,8 +152,7 @@ void QgsDecorationNorthArrowDialog::drawNorthArrow()
myQPainter.rotate( rotation );
//work out how to shift the image so that it appears in the center of the canvas
//(x cos a + y sin a - x, -x sin a + y cos a - y)
const double PI = 3.14159265358979323846;
double myRadiansDouble = ( PI / 180 ) * rotation;
double myRadiansDouble = ( M_PI / 180 ) * rotation;
int xShift = static_cast<int>( (
( centerXDouble * std::cos( myRadiansDouble ) ) +
( centerYDouble * std::sin( myRadiansDouble ) )
Expand Down
8 changes: 3 additions & 5 deletions src/app/qgsmaptoolrotatefeature.cpp
Expand Up @@ -36,8 +36,6 @@
#include <limits>
#include <cmath>

#define PI 3.14159265

QgsAngleMagnetWidget::QgsAngleMagnetWidget( const QString &label, QWidget *parent )
: QWidget( parent )
{
Expand Down Expand Up @@ -152,7 +150,7 @@ void QgsMapToolRotateFeature::canvasMoveEvent( QgsMapMouseEvent *e )
{
const double XDistance = e->pos().x() - mStPoint.x();
const double YDistance = e->pos().y() - mStPoint.y();
double rotation = std::atan2( YDistance, XDistance ) * ( 180 / PI );
double rotation = std::atan2( YDistance, XDistance ) * ( 180 / M_PI );

if ( mRotationWidget )
{
Expand Down Expand Up @@ -297,7 +295,7 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent *e )

double XDistance = mInitialPos.x() - mAnchorPoint->x();
double YDistance = mInitialPos.y() - mAnchorPoint->y() ;
mRotationOffset = std::atan2( YDistance, XDistance ) * ( 180 / PI );
mRotationOffset = std::atan2( YDistance, XDistance ) * ( 180 / M_PI );

createRotationWidget();
if ( e->modifiers() & Qt::ShiftModifier )
Expand Down Expand Up @@ -349,7 +347,7 @@ void QgsMapToolRotateFeature::applyRotation( double rotation )
}

//calculations for affine transformation
double angle = -1 * mRotation * ( PI / 180 );
double angle = -1 * mRotation * ( M_PI / 180 );
QgsPointXY anchorPoint = toLayerCoordinates( vlayer, mStartPointMapCoords );
double a = std::cos( angle );
double b = -1 * std::sin( angle );
Expand Down
4 changes: 0 additions & 4 deletions src/app/qgsmaptoolselectradius.cpp
Expand Up @@ -24,10 +24,6 @@ email : jpalmer at linz dot govt dot nz
#include <cmath>
#include <QMouseEvent>

#ifndef M_PI
#define M_PI 3.1415926535897931159979634685
#endif

const int RADIUS_SEGMENTS = 40;

QgsMapToolSelectRadius::QgsMapToolSelectRadius( QgsMapCanvas *canvas )
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsinternalgeometryengine.cpp
Expand Up @@ -373,7 +373,7 @@ QgsVector calcMotion( const QgsPoint &a, const QgsPoint &b, const QgsPoint &c,

// wonderful nasty hack which has survived through JOSM -> id -> QGIS
// to deal with almost-straight segments (angle is closer to 180 than to 90/270).
if ( dotProduct < -0.707106781186547 )
if ( dotProduct < -M_SQRT1_2 )
dotProduct += 1.0;

QgsVector new_v = p + q;
Expand Down
4 changes: 0 additions & 4 deletions src/core/pal/feature.cpp
Expand Up @@ -44,10 +44,6 @@
#include <cmath>
#include <cfloat>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

using namespace pal;

FeaturePart::FeaturePart( QgsLabelFeature *feat, const GEOSGeometry *geom )
Expand Down
4 changes: 0 additions & 4 deletions src/core/pal/labelposition.cpp
Expand Up @@ -38,10 +38,6 @@
#include <cmath>
#include <cfloat>

#ifndef M_PI
#define M_PI 3.1415926535897931159979634685
#endif

using namespace pal;

LabelPosition::LabelPosition( int id, double x1, double y1, double w, double h, double alpha, double cost, FeaturePart *feature, bool isReversed, Quadrant quadrant )
Expand Down
12 changes: 0 additions & 12 deletions src/core/pal/util.cpp
Expand Up @@ -37,18 +37,6 @@
#include "qgslogger.h"
#include <cfloat>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif

#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
#endif

void pal::Util::sort( void **items, int N, bool ( *greater )( void *l, void *r ) )
{

Expand Down
5 changes: 0 additions & 5 deletions src/core/qgsdistancearea.cpp
Expand Up @@ -34,11 +34,6 @@
#include "qgsunittypes.h"
#include "qgsexception.h"

// MSVC compiler doesn't have defined M_PI in math.h
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

#define DEG2RAD(x) ((x)*M_PI/180)
#define RAD2DEG(r) (180.0 * (r) / M_PI)
#define POW2(x) ((x)*(x))
Expand Down
4 changes: 0 additions & 4 deletions src/core/symbology/qgspointclusterrenderer.cpp
Expand Up @@ -24,10 +24,6 @@
#include "qgsproperty.h"
#include <cmath>

#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
#endif

QgsPointClusterRenderer::QgsPointClusterRenderer()
: QgsPointDistanceRenderer( QStringLiteral( "pointCluster" ) )
{
Expand Down
4 changes: 0 additions & 4 deletions src/core/symbology/qgspointdisplacementrenderer.cpp
Expand Up @@ -25,10 +25,6 @@
#include <QPainter>
#include <cmath>

#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
#endif

QgsPointDisplacementRenderer::QgsPointDisplacementRenderer( const QString &labelAttributeName )
: QgsPointDistanceRenderer( QStringLiteral( "pointDisplacement" ), labelAttributeName )
, mPlacement( Ring )
Expand Down
4 changes: 0 additions & 4 deletions src/core/symbology/qgspointdistancerenderer.cpp
Expand Up @@ -27,10 +27,6 @@

#include <cmath>

#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
#endif

QgsPointDistanceRenderer::QgsPointDistanceRenderer( const QString &rendererName, const QString &labelAttributeName )
: QgsFeatureRenderer( rendererName )
, mLabelAttributeName( labelAttributeName )
Expand Down
5 changes: 0 additions & 5 deletions src/core/symbology/qgssymbollayer.h
Expand Up @@ -15,11 +15,6 @@
#ifndef QGSSYMBOLLAYER_H
#define QGSSYMBOLLAYER_H

// MSVC compiler doesn't have defined M_PI in math.h
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

#define DEG2RAD(x) ((x)*M_PI/180)
#define DEFAULT_SCALE_METHOD QgsSymbol::ScaleDiameter

Expand Down

0 comments on commit 7f44737

Please sign in to comment.