From 94f565a00cbc8d779251355cdb94704277711da7 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 12 Jan 2017 18:02:46 +0100 Subject: Be (somewhat more) consistent about the value of pi Use M_PI in C++ and Math.PI in JavaScript (including QML). Use qmath.h's value for M_PI where we can't avoid an explicit value. Task-number: QTBUG-58083 Change-Id: I80c81444c1867f8f0c07f192fa68de933f48bbc4 Reviewed-by: Miikka Heikkinen --- examples/charts/openglseries/datasource.cpp | 2 +- examples/charts/qmloscilloscope/datasource.cpp | 2 +- examples/charts/scatterchart/chartview.cpp | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'examples/charts') diff --git a/examples/charts/openglseries/datasource.cpp b/examples/charts/openglseries/datasource.cpp index 3f8ae9a3..291bc722 100644 --- a/examples/charts/openglseries/datasource.cpp +++ b/examples/charts/openglseries/datasource.cpp @@ -117,7 +117,7 @@ void DataSource::generateData(int seriesCount, int rowCount, int colCount) qreal x(0); qreal y(0); // data with sin + random component - y = height + (yMultiplier * qSin(3.14159265358979 / 50 * j) + y = height + (yMultiplier * qSin(M_PI / 50 * j) + (yMultiplier * (qreal) rand() / (qreal) RAND_MAX)); // 0.000001 added to make values logaxis compatible x = 0.000001 + 20.0 * (qreal(j) / qreal(colCount)) + (xAdjustment * qreal(i)); diff --git a/examples/charts/qmloscilloscope/datasource.cpp b/examples/charts/qmloscilloscope/datasource.cpp index 3654dec0..f687beb0 100644 --- a/examples/charts/qmloscilloscope/datasource.cpp +++ b/examples/charts/qmloscilloscope/datasource.cpp @@ -82,7 +82,7 @@ void DataSource::generateData(int type, int rowCount, int colCount) switch (type) { case 0: // data with sin + random component - y = qSin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX; + y = qSin(M_PI / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX; x = j; break; case 1: diff --git a/examples/charts/scatterchart/chartview.cpp b/examples/charts/scatterchart/chartview.cpp index c2f099c1..f96497bc 100644 --- a/examples/charts/scatterchart/chartview.cpp +++ b/examples/charts/scatterchart/chartview.cpp @@ -34,8 +34,6 @@ #include #include -const float Pi = 3.14159f; - ChartView::ChartView(QWidget *parent) : QChartView(new QChart(), parent) { @@ -71,8 +69,8 @@ ChartView::ChartView(QWidget *parent) : QPainterPath starPath; starPath.moveTo(28, 15); for (int i = 1; i < 5; ++i) { - starPath.lineTo(14 + 14 * qCos(0.8 * i * Pi), - 15 + 14 * qSin(0.8 * i * Pi)); + starPath.lineTo(14 + 14 * qCos(0.8 * i * M_PI), + 15 + 14 * qSin(0.8 * i * M_PI)); } starPath.closeSubpath(); -- cgit v1.2.3