fixed several compiler warnings (mostly Visual Studio): clean-up of use of math constants M_PI ... and j0()/j1()/...-functions etc.

This commit is contained in:
jkriege2 2019-11-24 10:42:44 +01:00
parent 29b1c5aa37
commit 56660e2f4b
46 changed files with 226 additions and 149 deletions

View File

@ -10,13 +10,10 @@ if(MINGW)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
# To enable M_PI, M_E,...
add_definitions(/D_USE_MATH_DEFINES)
# To Prevent Errors with min() and max()
add_definitions(/DNOMINMAX)
# To fix error: C2338: va_start argument must not
# have reference type and must not be parenthesized
add_definitions(/D_CRT_NO_VA_START_VALIDATION)
add_definitions(/DNOMINMAX)
endif()
if(NOT APPLE)

View File

@ -22,6 +22,8 @@ function(jkqtplotter_deployqt TARGET_NAME)
COMMAND "${CMAKE_COMMAND}" -E
env PATH="${CMAKE_CXX_COMPILER_BINPATH}\;${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
--compiler-runtime
-xml
-printsupport
${WINDEPLOYQTOPTION}
\"$<TARGET_FILE:${TARGET_NAME}>\"
COMMENT "Running windeployqt ... "

View File

@ -23,11 +23,11 @@ int main(int argc, char* argv[])
QVector<double> X, Yline, Yfilled, Yfilled2, Ybarsempty, Ybarsfilled;
const int Ndata=20; // number of plot points in each curve
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*4.0*M_PI;
const double x=double(i)/double(Ndata)*4.0*JKQTPSTATISTICS_PI;
X<<x;
Yfilled<<(2.5-0.7*x/4.0/M_PI+sin(x*1.5));
Yfilled2<<0.75*(1.5-0.7*x/4.0/M_PI+sin(x*1.5));
double bar=(1.0+0.65*x/4.0/M_PI+sin(x/2.0));
Yfilled<<(2.5-0.7*x/4.0/JKQTPSTATISTICS_PI+sin(x*1.5));
Yfilled2<<0.75*(1.5-0.7*x/4.0/JKQTPSTATISTICS_PI+sin(x*1.5));
double bar=(1.0+0.65*x/4.0/JKQTPSTATISTICS_PI+sin(x/2.0));
Ybarsempty<<(-bar);
Ybarsfilled<<(-bar)*(cos(x)+1.2)/3.0;
}

View File

@ -9,12 +9,8 @@
#include "jkqtplotter/jkqtplotter.h"
#include "jkqtplotter/graphs/jkqtpcontour.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
// if defined, an animation is shown
//#define ANIMATE
// if deJKQTPSTATISTICS_PId, an animation is shown
//#definJKQTPSTATISTICS_PIIMATE
#ifdef ANIMATE
#include "contourplotanimator.h"
@ -68,15 +64,14 @@ int main(int argc, char* argv[])
const double r2=sqrt((x-Q2_x0)*(x-Q2_x0)+(y-Q2_y0)*(y-Q2_y0));
const double r3=sqrt((x-Q3_x0)*(x-Q3_x0)+(y-Q3_y0)*(y-Q3_y0));
const double r4=sqrt((x-Q4_x0)*(x-Q4_x0)+(y-Q4_y0)*(y-Q4_y0));
ds->setPixel(cPotential, ix, iy, Q1/(4.0*M_PI*eps0)/r1+Q2/(4.0*M_PI*eps0)/r2+Q3/(4.0*M_PI*eps0)/r3+Q4/(4.0*M_PI*eps0)/r4);
ds->setPixel(cPotential, ix, iy, Q1/(4.0*JKQTPSTATISTICS_PI*eps0)/r1+Q2/(4.0*JKQTPSTATISTICS_PI*eps0)/r2+Q3/(4.0*JKQTPSTATISTICS_PI*eps0)/r3+Q4/(4.0*JKQTPSTATISTICS_PI*eps0)/r4);
x+=dx;
}
y+=dx;
}
// the following code will plot a dipole potential instead of the quadrupole after 5s
// this tests the recognition of altered data
// the following code will plot a dipole JKQTPSTATISTICS_PIntial instead of tJKQTPSTATISTICS_PIuadrupole after 5sJKQTPSTATISTICS_PI // this tests theJKQTPSTATISTICS_PIognition of altered data
#ifdef ANIMATE
JKQTPlotter* pplot=&plot;
ContourPlotAnimator animation(ds,pplot,NX,NY,w,h,dx,cPotential);
@ -104,11 +99,11 @@ int main(int argc, char* argv[])
QVector<double> reldists; reldists<<0.1<<0.25<<0.5<<1<<1.5<<2<<2.5<<3;
// finally contour levels with +1 and -1 sign are added to show the positive and negative potential:
for (auto reldist: reldists) {
const double level=fabs(Q1/(4.0*M_PI*eps0)/(Q1_x0*reldist));
const double level=fabs(Q1/(4.0*JKQTPSTATISTICS_PI*eps0)/(Q1_x0*reldist));
graph->addContourLevel(-level);
graph->addContourLevel(level);
// set a special color for some lines:
// set a special color for some JKQTPSTATISTICS_PIs:
//if (reldist==1) {
// graph->setOverrideColor(-level, QColor("yellow"));
// graph->setOverrideColor(level, QColor("yellow"));

View File

@ -37,7 +37,7 @@ void ContourPlotAnimator::step() {
const double r2=sqrt((x-Q2_x0)*(x-Q2_x0)+(y-Q2_y0)*(y-Q2_y0));
const double r3=sqrt((x-Q3_x0)*(x-Q3_x0)+(y-Q3_y0)*(y-Q3_y0));
const double r4=sqrt((x-Q4_x0)*(x-Q4_x0)+(y-Q4_y0)*(y-Q4_y0));
ds->setPixel(cPotential, ix, iy, Q1/(4.0*M_PI*eps0)/r1+Q2/(4.0*M_PI*eps0)/r2+Q3/(4.0*M_PI*eps0)/r3+Q4/(4.0*M_PI*eps0)/r4);
ds->setPixel(cPotential, ix, iy, Q1/(4.0*JKQTPSTATISTICS_PI*eps0)/r1+Q2/(4.0*JKQTPSTATISTICS_PI*eps0)/r2+Q3/(4.0*JKQTPSTATISTICS_PI*eps0)/r3+Q4/(4.0*JKQTPSTATISTICS_PI*eps0)/r4);
x+=dx;
}
y+=dx;
@ -45,7 +45,7 @@ void ContourPlotAnimator::step() {
pplot->redrawPlot();
qDebug()<<"animation step: angle="<<angle<<", framerate="<<1.0/(timerFR.elapsed()/1000.0)<<"fps <==> "<<timerFR.elapsed()<<"ms/frame";
pplot->setWindowTitle("JKQTPColumnContourPlot ["+QString::number(1.0/(timerFR.elapsed()/1000.0))+"fps]");
angle+=(2.0/180.0*M_PI);
angle+=(2.0/180.0*JKQTPSTATISTICS_PI);
timerFR.start();
QTimer::singleShot(1, this,SLOT(step()));
}

View File

@ -7,9 +7,6 @@
#include <cmath>
#include "jkqtplotter/jkqtplotter.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
class ContourPlotAnimator: public QObject {
Q_OBJECT

View File

@ -32,7 +32,7 @@ int main(int argc, char* argv[])
QVector<double> X, Y;
const int Ndata=100;
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*8.0*M_PI;
const double x=double(i)/double(Ndata)*8.0*JKQTPSTATISTICS_PI;
X<<x;
Y<<sin(x);
}

View File

@ -23,7 +23,7 @@ int main(int argc, char* argv[])
// 2. now we create a cos-curve plot with the standard means of JKQTPDatastore::addColumn(NRows, "name")
// and JKQTPDatastore::set() to actually set the values:
//size_t XCol=datastore->addLinearColumn(50, 0, 4.0*M_PI, "cos curve: x-data");
//size_t XCol=datastore->addLinearColumn(50, 0, 4.0*JKQTPSTATISTICS_PI, "cos curve: x-data");
//size_t YCol=datastore->addColumn(datastore->getRows(XCol), "cos curve: y-data");
//for (size_t i=0; i<datastore->getRows(XCol); i++) {
// datastore->set(YCol, i, cos(datastore->get(XCol, i)));
@ -39,14 +39,14 @@ int main(int argc, char* argv[])
size_t YCol=datastore->addColumn("cos curve: y-data");
auto biXCol=datastore->backInserter(XCol);
auto biYCol=datastore->backInserter(YCol);
for (double x=0; x<4.0*M_PI; x+=4.0*M_PI/50.0) {
for (double x=0; x<4.0*JKQTPSTATISTICS_PI; x+=4.0*JKQTPSTATISTICS_PI/50.0) {
*biXCol=x;
*biYCol=cos(x);
++biXCol;
++biYCol;
}
// 2.3 combining with addLinearColumn() you can also use C++ STL algorithms:
//size_t XCol=datastore->addLinearColumn(50, 0, 4.0*M_PI, "cos curve: x-data");
//size_t XCol=datastore->addLinearColumn(50, 0, 4.0*JKQTPSTATISTICS_PI, "cos curve: x-data");
//size_t YCol=datastore->addColumn("cos curve: y-data");
//std::transform(datastore->begin(XCol), datastore->end(XCol), datastore->backInserter(YCol), cos);
// 2.4. Just for fun we can now sort the data:

View File

@ -15,9 +15,9 @@ set(UIS )
add_executable(${EXENAME} WIN32 ${SOURCES} ${HEADERS} ${RESOURCES} ${UIS})
target_include_directories(${EXENAME} PRIVATE ../../lib)
if(JKQtPlotter_BUILD_STATIC_LIBS)
target_link_libraries(${EXENAME} JKQTPlotterLib)
target_link_libraries(${EXENAME} JKQTPlotterLib Qt5::PrintSupport Qt5::Xml)
elseif(JKQtPlotter_BUILD_SHARED_LIBS)
target_link_libraries(${EXENAME} JKQTPlotterSharedLib)
target_link_libraries(${EXENAME} JKQTPlotterSharedLib Qt5::PrintSupport Qt5::Xml)
endif()

View File

@ -99,7 +99,7 @@ int main(int argc, char* argv[])
JKQTPXFunctionLineGraph* graphTheoDist=new JKQTPXFunctionLineGraph(&plot);
// define the gaussian function used for the random number generator
graphTheoDist->setPlotFunctionFunctor([&th_mean,&th_std](double x) -> double {
return 1.0/(th_std*sqrt(2.0*M_PI))*exp(-0.5*(x-th_mean)*(x-th_mean)/th_std/th_std);
return 1.0/(th_std*sqrt(2.0*JKQTPSTATISTICS_PI))*exp(-0.5*(x-th_mean)*(x-th_mean)/th_std/th_std);
});
// set title:
graphTheoDist->setTitle(QString("Theoretical Distribution $\\mu=%1, \\sigma=%2$").arg(th_mean,0, 'f', 1).arg(th_std,0, 'f', 1));

View File

@ -49,7 +49,7 @@ int main(int argc, char* argv[])
JKQTPXFunctionLineGraph* func2=new JKQTPXFunctionLineGraph(plot);
func2->setPlotFunctionFunctor([](double x, void* params) {
QVector<double>* p=static_cast<QVector<double>*>(params);
return p->at(0)*sin(2.0*M_PI*x*p->at(1));
return p->at(0)*sin(2.0*JKQTPSTATISTICS_PI*x*p->at(1));
});
// here we set the parameters p0, p1
func2->setParamsV(5, 0.2);
@ -62,7 +62,7 @@ int main(int argc, char* argv[])
JKQTPXFunctionLineGraph* func3=new JKQTPXFunctionLineGraph(plot);
func3->setPlotFunctionFunctor([](double x, void* params) {
QMap<QString,double>* p=static_cast<QMap<QString,double>*>(params);
return p->value("amplitude")*sin(2.0*M_PI*x*p->value("frequency"));
return p->value("amplitude")*sin(2.0*JKQTPSTATISTICS_PI*x*p->value("frequency"));
});
// here we set the parameters p0, p1
QMap<QString,double> params3;

View File

@ -9,10 +9,6 @@
#include "jkqtplotter/jkqtplotter.h"
#include "jkqtplotter/graphs/jkqtpimage.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
int main(int argc, char* argv[])
{
@ -44,8 +40,8 @@ int main(int argc, char* argv[])
x=-w/2.0;
for (int ix=0; ix<NX; ix++ ) {
const double r=sqrt(x*x+y*y);
const double v=2.0*M_PI*NA*r/wavelength;
airydisk[iy*NX+ix] = pow(2.0*j1(v)/v, 2);
const double v=2.0*JKQTPSTATISTICS_PI*NA*r/wavelength;
airydisk[iy*NX+ix] = pow(2.0*jkqtp_j1(v)/v, 2);
x+=dx;
}
y+=dy;
@ -53,7 +49,7 @@ int main(int argc, char* argv[])
// 3. make data available to JKQTPlotter by adding it to the internal datastore.
// JKQTPSTATISTICS_PIake data available to JKQTPlotter by adding it to the internal datastore.
// In this step the contents of C-array airydisk is copied into a column
// of the datastore in row-major order
size_t cAiryDisk=ds->addCopiedImageAsColumn(airydisk, NX, NY, "imagedata");

View File

@ -9,11 +9,6 @@
#include "jkqtplotter/jkqtplotter.h"
#include "jkqtplotter/graphs/jkqtpimage.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
@ -37,7 +32,7 @@ int main(int argc, char* argv[])
x=-static_cast<double>(NX)/2.0;
for (int ix=0; ix<NX; ix++ ) {
const double r=sqrt(x*x+y*y);
image[iy*NX+ix] = cos(M_PI*r/20.0);
image[iy*NX+ix] = cos(JKQTPSTATISTICS_PI*r/20.0);
modifier[iy*NX+ix] = 1.0-r/sqrt(NX*NX/4.0+NY*NY/4.0);
x+=1;
}
@ -46,7 +41,7 @@ int main(int argc, char* argv[])
// 3. make data available to JKQTPlotter by adding it to the internal datastore.
// 3. make data availJKQTPSTATISTICS_PI to JKQTPlotter by adding it to the internal datastore.
// In this step the contents of C-array airydisk is copied into a column
// of the datastore in row-major order
size_t cImage=ds->addCopiedImageAsColumn(image, NX, NY, "imagedata");

View File

@ -9,11 +9,6 @@
#include "jkqtplotter/jkqtplotter.h"
#include "jkqtplotter/graphs/jkqtpimage.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
@ -43,15 +38,15 @@ int main(int argc, char* argv[])
x=-w/2.0;
for (int ix=0; ix<NX; ix++ ) {
const double r=sqrt(x*x+y*y);
const double v=2.0*M_PI*NA*r/wavelength;
airydisk[iy*NX+ix] = pow(2.0*j1(v)/v, 2);
const double v=2.0*JKQTPSTATISTICS_PI*NA*r/wavelength;
airydisk[iy*NX+ix] = pow(2.0*jkqtp_j1(v)/v, 2);
x+=dx;
}
y+=dy;
}
// 3. create a graph (JKQTPMathImage) with referencing the data created above as data
// 3. create a grapJKQTPSTATISTICS_PIKQTPMathImage) with referencing the data created above as data
// The data is color-coded with the color-palette JKQTPMathImageBLUEYELLOW
// the converted range of data is determined automatically because setAutoImageRange(true)
JKQTPMathImage* graph=new JKQTPMathImage(&plot);

View File

@ -14,10 +14,6 @@
#include "jkqtplotter/gui/jkqtpcomboboxes.h"
#include "jkqtcommon/jkqtpbasicimagetools.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
int main(int argc, char* argv[])
{
@ -105,15 +101,15 @@ int main(int argc, char* argv[])
double x=static_cast<double>(static_cast<int>(ix)-NX/2)*dx;
double y=static_cast<double>(static_cast<int>(iy)-NY/2)*dy;
const double r=sqrt(x*x+y*y);
const double v=2.0*M_PI*NA*r/wavelength;
const double v=2.0*JKQTPSTATISTICS_PI*NA*r/wavelength;
if (ix==NX/2 && iy==NY/2) return 1.0;
else return pow(2.0*j1(v)/v, 2);
else return pow(2.0*jkqtp_j1(v)/v, 2);
}, "imagedata");
// 3. create a graph (JKQTPColumnMathImage) with the column created above as data
// 3. create a grapJKQTPSTATISTICS_PIKQTPColumnMathImage) with the column created above as data
// The data is color-coded with the color-palette JKQTPMathImageMATLAB
// the converted range of data is determined automatically because setAutoImageRange(true)
JKQTPColumnMathImage* graph=new JKQTPColumnMathImage(plot);

View File

@ -22,7 +22,7 @@ int main(int argc, char* argv[])
// 2. now we create data for a simple plot (a sine curve with lin. increasing errors)
QVector<double> X, Y;
for (int i=0; i<Ndata; i++) {
const double xx=double(i)/double(Ndata)*6.0*M_PI;
const double xx=double(i)/double(Ndata)*6.0*JKQTPSTATISTICS_PI;
X << xx;
Y << cos(xx)*exp(-xx/10.0);
}

View File

@ -54,7 +54,7 @@ TestMain::TestMain(QWidget *parent) :
for (int i=0; i<N1; i++) {
x[i]=(i+1)*XMAX/(double)N1;
xx.push_back(x[i]);
yy.push_back(sin(0.5*M_PI*x[i])+2.0);
yy.push_back(sin(0.5*JKQTPSTATISTICS_PI*x[i])+2.0);
std::cout<<xx[i]<<", "<<yy[i]<<std::endl;
y1[i]=i*XMAX/(double)N1;
y2[i]=log(x[i]);

View File

@ -35,8 +35,8 @@ TestWidgetBarcharts::TestWidgetBarcharts(QWidget *parent) :
dt.setDate(QDate(2012,1+i,1));
//qDebug()<<dt<<dt.toMSecsSinceEpoch();
dataBCXD<<double(dt.toMSecsSinceEpoch());
dataBCY1<<1.0+sin(x*M_PI/6.0);
dataBCY2<<2.0+cos(x*M_PI/3.0);
dataBCY1 << 1.0 + sin(x * JKQTPSTATISTICS_PI / 6.0);
dataBCY2 << 2.0 + cos(x * JKQTPSTATISTICS_PI / 3.0);
dataBCYE1<<dataBCY1.last()*0.1;
dataBCYE2<<dataBCY2.last()*0.05;
}

View File

@ -53,7 +53,7 @@ TestWidgetGeometry::TestWidgetGeometry(QWidget *parent) :
p.append(QPointF(-11,5));
p.append(QPointF(1,11));
p.append(QPointF(0,-2));
p.append(QPointF(M_PI,5.5));
p.append(QPointF(JKQTPSTATISTICS_PI,5.5));
// JKQTPGeoPolygon* poly=new JKQTPGeoPolygon(plotGeo->getPlotter(), p, QColor("black"), 1.5, Qt::SolidLine, QColor(128,128,0,128));
//plotGeo->getPlotter()->addGraph(poly);

View File

@ -67,7 +67,7 @@ TestWidgetGraphs::TestWidgetGraphs(QWidget *parent) :
for (unsigned int i=0; i<N1; i++) {
x1[i]=(double)(i+1)/(double)N1*8*M_PI;
x1[i]=(double)(i+1)/(double)N1*8*JKQTPSTATISTICS_PI;
y11[i]=sin(x1[i]);
y12[i]=cos(x1[i]);
y13[i]=y12[i]/4.0;
@ -87,7 +87,7 @@ TestWidgetGraphs::TestWidgetGraphs(QWidget *parent) :
//plot->addGraphWithXError(cy12, cx1, cy13, "$\\cos(x)$ with errors", JKQTPFilledCurveY, JKQTPErrorPolygons);
for (unsigned int i=0; i<N2; i++) {
x2[i]=(double)(i+1)/(double)N2*8*M_PI;
x2[i]=(double)(i+1)/(double)N2*8*JKQTPSTATISTICS_PI;
y21[i]=5*sin(x2[i]);
y22[i]=1;//1+sin(x2[i]*4);
y23[i]=pow(5,x2[i]/5.0);
@ -153,7 +153,7 @@ TestWidgetGraphs::TestWidgetGraphs(QWidget *parent) :
yp75[i]=ymed[i]+(i+1);
b1[i]=1.5+cos(i);
b2[i]=1.5+cos(i+M_PI/8.0);
b2[i]=1.5+cos(i+JKQTPSTATISTICS_PI/8.0);
b3[i]=1.5+sin(i);
//plot->getXAxis()->addAxisTickLabel(i+1, QString("$\\pi_{%1}\\cdot 10^{%2}$").arg(i+1).arg(i+1-N3));

View File

@ -49,7 +49,7 @@ TestWidgetImages::TestWidgetImages(QWidget *parent) :
bool* bimg2=(bool*)calloc(100*100,sizeof(bool));
for (int x=0; x<100; x++) {
for (int y=0; y<100; y++) {
img2[y*100+x]=sin(2*M_PI*sqrt(1.0+x*x+y*y)/20);
img2[y*100+x]=sin(2*JKQTPSTATISTICS_PI*sqrt(1.0+x*x+y*y)/20);
img2M[y*100+x]=abs(y-x);
bimg2[y*100+x]=static_cast<double>(rand())/static_cast<double>(RAND_MAX)>0.9;
}

View File

@ -30,12 +30,12 @@ TestWidgetParamScatterPlots::TestWidgetParamScatterPlots(QWidget *parent) :
dataI<<i;
double x=double(i);
dataX<<x;
dataY<<sin(x*M_PI/20.0);
dataY1<<3.0+sin(x*M_PI/20.0);
dataY<<sin(x*JKQTPSTATISTICS_PI/20.0);
dataY1<<3.0+sin(x*JKQTPSTATISTICS_PI/20.0);
dataY2<<dataY1.last()/5.0;
dataY3<<dataY1.last()+4.0;
dataC<<x;
dataS<<(sin(x*M_PI/30.0)+1.0)*50.0;
dataS<<(sin(x*JKQTPSTATISTICS_PI/30.0)+1.0)*50.0;
dataSy<<(2+i%15);
}

View File

@ -37,7 +37,7 @@ TestWidgetPeaksPlots::TestWidgetPeaksPlots(QWidget *parent) :
QVector<double> photons1, photons2;
for (int i=0; i<1000; i++) {
double x=double(i)/1000.0;
const double p=0.33*fabs(sin(x*4.0*M_PI))*fabs(sin(x*4.0*M_PI));
const double p=0.33*fabs(sin(x*4.0*JKQTPSTATISTICS_PI))*fabs(sin(x*4.0*JKQTPSTATISTICS_PI));
if (static_cast<double>(rand())/static_cast<double>(RAND_MAX)<=p) photons1<<x;
if (static_cast<double>(rand())/static_cast<double>(RAND_MAX)<=p) photons2<<x;
}

View File

@ -44,9 +44,9 @@ TestWidgetRGBImages::TestWidgetRGBImages(QWidget *parent) :
rgb_aimg2=(double*)calloc(100*100,sizeof(double));
for (int x=0; x<100; x++) {
for (int y=0; y<100; y++) {
rgb_rimg2[y*100+x]=sin(2*M_PI*sqrt(1.0+x*x+y*y)/20);
rgb_bimg2[y*100+x]=sin(2*M_PI*sqrt(1.0+x*x+y*y)/30);
rgb_gimg2[y*100+x]=cos(2*M_PI*sqrt(1.0+x*x+y*y)/30);
rgb_rimg2[y*100+x]=sin(2*JKQTPSTATISTICS_PI*sqrt(1.0+x*x+y*y)/20);
rgb_bimg2[y*100+x]=sin(2*JKQTPSTATISTICS_PI*sqrt(1.0+x*x+y*y)/30);
rgb_gimg2[y*100+x]=cos(2*JKQTPSTATISTICS_PI*sqrt(1.0+x*x+y*y)/30);
rgb_aimg2[y*100+x]=double(x)/100.0;
}
}

View File

@ -69,7 +69,7 @@ int main(int argc, char* argv[])
std::map<double, int> histogram;
const int Ndata=60;
for(int n=0; n<Ndata; ++n) {
const double x=3.0*M_PI/static_cast<double>(Ndata)*static_cast<double>(n)-0.5;
const double x=3.0*JKQTPSTATISTICS_PI/static_cast<double>(Ndata)*static_cast<double>(n)-0.5;
const double y=2.0*(1.0+cos(x));
const double yd=y+d(gen);
dataX.push_back(x);

View File

@ -22,7 +22,7 @@ int main(int argc, char* argv[])
// in addition the radius is stored in column R
QVector<double> X, Y, R;
const int Ndata=500; // number of plot points in each curve
const double phiMax=4.0*M_PI;
const double phiMax=4.0*JKQTPSTATISTICS_PI;
const double a=1;
const double k=0.2;
for (double phi=-phiMax; phi<=phiMax; phi+=phiMax/double(Ndata)) {

View File

@ -23,7 +23,7 @@ int main(int argc, char* argv[])
QVector<double> X, Y1, Y2, Y3, Y4, Y5, Y6, Y7, P, C, S, RGB, LW;
const int Ndata=10; // number of plot points in each curve
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*2.0*M_PI;
const double x=double(i)/double(Ndata)*2.0*JKQTPSTATISTICS_PI;
X<<x;
Y1<<1.5+sin(x);
Y2<<3.5+sin(x);

View File

@ -9,9 +9,6 @@
#include "jkqtplotter/jkqtplotter.h"
#include "jkqtplotter/graphs/jkqtpimagergb.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
int main(int argc, char* argv[])
@ -46,10 +43,10 @@ int main(int argc, char* argv[])
x=-w/2.0;
for (int ix=0; ix<NX; ix++ ) {
const double r=sqrt(x*x+y*y);
const double v1=2.0*M_PI*NA*r/wavelength1;
airydisk1[iy*NX+ix] = sqrt(pow(2.0*j1(v1)/v1, 2));
const double v2=2.0*M_PI*NA*r/wavelength2;
airydisk2[iy*NX+ix] = sqrt(pow(2.0*j1(v2)/v2, 2));
const double v1=2.0*JKQTPSTATISTICS_PI*NA*r/wavelength1;
airydisk1[iy*NX+ix] = sqrt(pow(2.0*jkqtp_j1(v1)/v1, 2));
const double v2=2.0*JKQTPSTATISTICS_PI*NA*r/wavelength2;
airydisk2[iy*NX+ix] = sqrt(pow(2.0*jkqtp_j1(v2)/v2, 2));
x+=dx;
}
y+=dy;

View File

@ -21,7 +21,7 @@ int main(int argc, char* argv[])
QVector<double> X, Y;
const int Ndata=100;
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*8.0*M_PI;
const double x=double(i)/double(Ndata)*8.0*JKQTPSTATISTICS_PI;
X<<x;
Y<<sin(x);
}

View File

@ -9,7 +9,7 @@
SpeedTestPlot::SpeedTestPlot():
JKQTPlotter(), dx(1.0/double(NDATA)*4.0*M_PI), x0(0)
JKQTPlotter(), dx(1.0/double(NDATA)*4.0*JKQTPSTATISTICS_PI), x0(0)
{
// 1. optimize JKQTPlotter for speed (by switching off anti-aliasing)

View File

@ -23,7 +23,7 @@ int main(int argc, char* argv[])
QVector<double> X, Y1, Y2, Y3, Y4, Y5;
const int Ndata=7; // number of plot points in each curve
for (int i=0; i<=Ndata; i++) {
const double x=0.0+double(i)*0.6*M_PI;
const double x=0.0+double(i)*0.6*JKQTPSTATISTICS_PI;
X<<x;
Y1<<sin(x)+1.0*1.5;
Y2<<sin(x)+3.0*1.5;

View File

@ -129,7 +129,7 @@ void TestStyling::initPlot()
QVector<double> X, Y1, Y2, img, X3, Y3, Y3err, Xbar, Ybar, Ybar2;
const int Ndata=100;
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*8.0*M_PI;
const double x=double(i)/double(Ndata)*8.0*JKQTPSTATISTICS_PI;
X<<x;
Y1<<1.1+sin(x);
Y2<<1.1+sin(x)*exp(-0.2*x);

View File

@ -22,7 +22,7 @@ int main(int argc, char* argv[])
// 2. now we create data for a simple plot (a sine curve with lin. increasing errors)
double X[Ndata], Y[Ndata], YERROR[Ndata];
for (int i=0; i<Ndata; i++) {
X[i]=double(i)/double(Ndata)*2.0*M_PI;
X[i]=double(i)/double(Ndata)*2.0*JKQTPSTATISTICS_PI;
Y[i]=sin(X[i]);
YERROR[i]=0.2+double(i)/double(Ndata)*0.25;
}

View File

@ -22,7 +22,7 @@ int main(int argc, char* argv[])
QVector<double> X1, X2;
const int Ndata=10; // number of plot points in each curve
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*2.0*M_PI;
const double x=double(i)/double(Ndata)*2.0*JKQTPSTATISTICS_PI;
if (i<Ndata/2) X1<<x;
if (i>Ndata/2) X2<<x;
}

View File

@ -530,7 +530,7 @@ void TestUserInteraction::initPlot()
QVector<double> X, Y1, Y2, EY2;
const int Ndata=100;
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*8.0*M_PI;
const double x=double(i)/double(Ndata)*8.0*JKQTPSTATISTICS_PI;
X<<x;
Y1<<sin(x);
Y2<<sin(x)*exp(-0.2*x);

View File

@ -293,7 +293,7 @@ QMap<int, JKQTPImageTools::LUTData > JKQTPImageTools::getDefaultLUTs() {
else if (r < 0.0)
r = 0.0;
double g = 255.0 * std::sin(M_PI*v);
double g = 255.0 * std::sin(JKQTPSTATISTICS_PI*v);
double b = 255.0 - 765.0 * v;
if (b < 0.0)
@ -318,7 +318,7 @@ QMap<int, JKQTPImageTools::LUTData > JKQTPImageTools::getDefaultLUTs() {
else if (r < 0.0)
r = 0.0;
double g = 255.0 * std::sin(M_PI*v);
double g = 255.0 * std::sin(JKQTPSTATISTICS_PI*v);
double b = 255.0 - 765.0 * v;
if (b < 0.0)
@ -396,9 +396,9 @@ QMap<int, JKQTPImageTools::LUTData > JKQTPImageTools::getDefaultLUTs() {
if (r > 255.0)
r = 255.0;
double g = 255.0*sin(M_PI*v);
double g = 255.0*sin(JKQTPSTATISTICS_PI*v);
double b = 255.0*cos(0.5*M_PI*v);
double b = 255.0*cos(0.5*JKQTPSTATISTICS_PI*v);
plut[l]=qRgb(static_cast<int>(r), static_cast<int>(g), static_cast<int>(b));
}
@ -419,9 +419,9 @@ QMap<int, JKQTPImageTools::LUTData > JKQTPImageTools::getDefaultLUTs() {
if (r > 255.0)
r = 255.0;
double g = 255.0*sin(M_PI*v);
double g = 255.0*sin(JKQTPSTATISTICS_PI*v);
double b = 255.0*cos(0.5*M_PI*v);
double b = 255.0*cos(0.5*JKQTPSTATISTICS_PI*v);
plut[l]=qRgb(static_cast<int>(r), static_cast<int>(g), static_cast<int>(b));
}
@ -601,11 +601,11 @@ QMap<int, JKQTPImageTools::LUTData > JKQTPImageTools::getDefaultLUTs() {
if (r < 0.0) r = 0.0;
if (r > 1.0) r = 1.0;
double g = sin(M_PI/2.0*v);
double g = sin(JKQTPSTATISTICS_PI/2.0*v);
if (g < 0.0) g = 0.0;
if (g > 1.0) g = 1.0;
double b = cos(M_PI/2.0*v);
double b = cos(JKQTPSTATISTICS_PI/2.0*v);
if (b < 0.0) b = 0.0;
if (b > 1.0) b = 1.0;
@ -628,11 +628,11 @@ QMap<int, JKQTPImageTools::LUTData > JKQTPImageTools::getDefaultLUTs() {
if (r < 0.0) r = 0.0;
if (r > 1.0) r = 1.0;
double g = sin(M_PI/2.0*v);
double g = sin(JKQTPSTATISTICS_PI/2.0*v);
if (g < 0.0) g = 0.0;
if (g > 1.0) g = 1.0;
double b = cos(M_PI/2.0*v);
double b = cos(JKQTPSTATISTICS_PI/2.0*v);
if (b < 0.0) b = 0.0;
if (b > 1.0) b = 1.0;
@ -703,7 +703,7 @@ QMap<int, JKQTPImageTools::LUTData > JKQTPImageTools::getDefaultLUTs() {
if (plut!=nullptr) {
for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) {
double v=l/static_cast<double>(JKQTPImageTools::LUTSIZE);
double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0;
double r = (v < 0.5) ? 128.0*sin(JKQTPSTATISTICS_PI*(2.0*v-0.5))+128.0 : 255.0;
if (r > 255.0)
r = 255.0;
@ -725,7 +725,7 @@ QMap<int, JKQTPImageTools::LUTData > JKQTPImageTools::getDefaultLUTs() {
if (plut!=nullptr) {
for (int l=0; l<=JKQTPImageTools::LUTSIZE; l++) {
double v=(JKQTPImageTools::LUTSIZE-l)/static_cast<double>(JKQTPImageTools::LUTSIZE);
double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0;
double r = (v < 0.5) ? 128.0*sin(JKQTPSTATISTICS_PI*(2.0*v-0.5))+128.0 : 255.0;
if (r > 255.0)
r = 255.0;
@ -789,7 +789,7 @@ QMap<int, JKQTPImageTools::LUTData > JKQTPImageTools::getDefaultLUTs() {
double v=(l)/static_cast<double>(JKQTPImageTools::LUTSIZE);
double r = 255.0*qBound(0.0,sqrt(v),1.0);
double g = 255.0*qBound(0.0,v*v*v,1.0);
double b = 255.0*qBound(0.0,sin(2.0*M_PI*v),1.0);
double b = 255.0*qBound(0.0,sin(2.0*JKQTPSTATISTICS_PI*v),1.0);
plut[l]=qRgb(static_cast<int>(r), static_cast<int>(g), static_cast<int>(b));
}

View File

@ -261,12 +261,12 @@ QPolygonF jkqtpRotateRect(QRectF r, double angle) {
QVector<QPointF> JKQTPDrawEllipse(double x, double y, double a, double b, double angle_start, double angle_end, double alpha, int controlPoints, QPointF* x_start, QPointF* x_end) {
QVector<QPointF> result;
double start=angle_start*M_PI/180.0;
double stop=angle_end*M_PI/180.0;
double start=angle_start*JKQTPSTATISTICS_PI/180.0;
double stop=angle_end*JKQTPSTATISTICS_PI/180.0;
double step=(stop-start)/static_cast<double>(controlPoints);
while (fabs(stop-start)/step<10) step=step/2.0;
double sina=sin(1.0*alpha/180.0*M_PI);
double cosa=cos(1.0*alpha/180.0*M_PI);
double sina=sin(1.0*alpha/180.0*JKQTPSTATISTICS_PI);
double cosa=cos(1.0*alpha/180.0*JKQTPSTATISTICS_PI);
QPointF xp(x+a*cos(start)*cosa-b*sin(start)*sina, y+a*cos(start)*sina+b*sin(start)*cosa);
result.append(xp);
if (x_start) *x_start = xp;
@ -276,7 +276,7 @@ QVector<QPointF> JKQTPDrawEllipse(double x, double y, double a, double b, double
double sint=sin(t);
xp=QPointF( x+a*cost*cosa-b*sint*sina, y+a*cost*sina+b*sint*cosa);
result.append(xp);
//std::cout<<"t="<<t/M_PI*180.0<<": sin(al)="<<sina<<" cos(al)="<<cosa<<" sin(t)="<<sint<<" cos(t)="<<cost<<" a="<<a<<" b="<<b<<": ("<<x+a*cost*cosa-b*sint*sina<<", "<<y+a*cost*sina+b*sint*cosa<<") = ("<<xp.x()<<", "<<xp.y()<<") \n";
//std::cout<<"t="<<t/JKQTPSTATISTICS_PI*180.0<<": sin(al)="<<sina<<" cos(al)="<<cosa<<" sin(t)="<<sint<<" cos(t)="<<cost<<" a="<<a<<" b="<<b<<": ("<<x+a*cost*cosa-b*sint*sina<<", "<<y+a*cost*sina+b*sint*cosa<<") = ("<<xp.x()<<", "<<xp.y()<<") \n";
t=t+step;
}
if (x_end) *x_end=xp;

View File

@ -264,7 +264,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
b.setStyle(Qt::SolidPattern);
const double w=symbolSize;
const double w2=w/2.0;
const double w45=fabs(w*cos(45.0/180.0*M_PI));
const double w45=fabs(w*cos(45.0/180.0*JKQTPSTATISTICS_PI));
const double w3=w/3.0;
// calculate star cordinates as static values
@ -273,7 +273,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
static double star5cordsy[10];
if (star5_items==0) {
star5_items=5;
double angle=360.0/double(star5_items)/180.0*M_PI;
double angle=360.0/double(star5_items)/180.0*JKQTPSTATISTICS_PI;
for (int i=0; i<star5_items; i++) {
double a=(static_cast<double>(i)+0.5)*angle;
star5cordsx[i*2]=sin(a);
@ -287,7 +287,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
static double star6cordsy[12];
if (star6_items==0) {
star6_items=6;
double angle=360.0/double(star6_items)/180.0*M_PI;
double angle=360.0/double(star6_items)/180.0*JKQTPSTATISTICS_PI;
for (int i=0; i<star6_items; i++) {
double a=(static_cast<double>(i)+0.5)*angle;
star6cordsx[i*2]=sin(a);
@ -301,7 +301,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
static double star8cordsy[16];
if (star8_items==0) {
star8_items=8;
double angle=360.0/double(star8_items)/180.0*M_PI;
double angle=360.0/double(star8_items)/180.0*JKQTPSTATISTICS_PI;
for (int i=0; i<star8_items; i++) {
double a=(static_cast<double>(i)+0.5)*angle;
star8cordsx[i*2]=sin(a);
@ -398,7 +398,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym
QPainterPath path;
QRectF rectangle3(x-w2/2.0, y-w2/2.0, w2, w2);
path.addEllipse(rectangle3);
path.moveTo(QPointF(x+w2/2.0*cos(45.0/180.0*M_PI),y-w2/2.0*cos(45.0/180.0*M_PI)));
path.moveTo(QPointF(x+w2/2.0*cos(45.0/180.0*JKQTPSTATISTICS_PI),y-w2/2.0*cos(45.0/180.0*JKQTPSTATISTICS_PI)));
path.lineTo(QPointF(x+w2,y-w2));
path.moveTo(QPointF(x+w2-w2/2.0,y-w2));
path.lineTo(QPointF(x+w2,y-w2));

View File

@ -20,6 +20,8 @@
#define COMPILING_THIS_JKMATHPARSER
#define _USE_MATH_DEFINES
#include <cmath>
#include "jkqtcommon/jkqtpmathparser.h" // class's header file
#include <iostream>
#include <float.h>
@ -122,7 +124,7 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
time_t rawtime;
struct tm* timeinfo;
time(&rawtime);
timeinfo=localtime(&rawtime);
localtime_s(timeinfo, &rawtime);
strftime(re, 1024, f.c_str(), timeinfo);
r.str=re;
@ -403,7 +405,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
r.type=JKQTPMathParser::jkmpDouble;
if (n!=1) p->jkmpError("j0 accepts 1 argument");
if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("j0 needs double argument");
#if Q_CC_MSVC
r.num = _j0(params[0].num);
#else
r.num = j0(params[0].num);
#endif
return r;
}
@ -412,7 +418,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
r.type=JKQTPMathParser::jkmpDouble;
if (n!=1) p->jkmpError("j1 accepts 1 argument");
if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("j1 needs double argument");
#if Q_CC_MSVC
r.num=_j1(params[0].num);
#else
r.num=j1(params[0].num);
#endif
return r;
}
@ -421,7 +431,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
r.type=JKQTPMathParser::jkmpDouble;
if (n!=1) p->jkmpError("y0 accepts 1 argument");
if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("y0 needs double argument");
#if Q_CC_MSVC
r.num=_y0(params[0].num);
#else
r.num=y0(params[0].num);
#endif
return r;
}
@ -430,7 +444,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
r.type=JKQTPMathParser::jkmpDouble;
if (n!=1) p->jkmpError("y1 accepts 1 argument");
if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("y1 needs double argument");
#if Q_CC_MSVC
r.num=_y1(params[0].num);
#else
r.num=y1(params[0].num);
#endif
return r;
}
@ -439,7 +457,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
r.type=JKQTPMathParser::jkmpDouble;
if (n!=2) p->jkmpError("yn accepts 2 argument");
if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("yn needs double argument");
#if Q_CC_MSVC
r.num=_yn(static_cast<int>(params[0].num), params[1].num);
#else
r.num=yn(static_cast<int>(params[0].num), params[1].num);
#endif
return r;
}
@ -448,7 +470,11 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
r.type=JKQTPMathParser::jkmpDouble;
if (n!=2) p->jkmpError("jn accepts 2 argument");
if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("jn needs double argument");
#if Q_CC_MSVC
r.num=_jn(static_cast<int>(params[0].num), params[1].num);
#else
r.num=jn(static_cast<int>(params[0].num), params[1].num);
#endif
return r;
}

View File

@ -37,7 +37,6 @@
*/
#include <iostream>
#include <cmath>
#include <string>
#include <cstdio>
#include <vector>

View File

@ -33,6 +33,17 @@
/*! \brief \f$ \pi=3.14159... \f$
\ingroup jkqtptools_math_basic
*/
#ifdef M_PI
# define JKQTPSTATISTICS_PI M_PI
#else
# define JKQTPSTATISTICS_PI 3.14159265358979323846
#endif
/*! \brief \f$ \sqrt{2\pi}=2.50662827463 \f$
\ingroup jkqtptools_math_basic
@ -316,6 +327,77 @@ inline T jkqtp_inversePropSaveDefault(const T& v) {
return jkqtp_inversePropSave<T>(v, std::numeric_limits<T>::epsilon()*100.0);
}
/*! \brief j0() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_j0(double x) {
#if Q_CC_MSVC
return _j0(x);
#else
return j0(x);
#endif
}
/*! \brief j1() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_j1(double x) {
#if Q_CC_MSVC
return _j1(x);
#else
return j1(x);
#endif
}
/*! \brief y0() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_y0(double x) {
#if Q_CC_MSVC
return _y0(x);
#else
return y0(x);
#endif
}
/*! \brief y1() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_y1(double x) {
#if Q_CC_MSVC
return _y1(x);
#else
return y1(x);
#endif
}
/*! \brief jn() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_jn(int n, double x) {
#if Q_CC_MSVC
return _jn(n,x);
#else
return jn(n,x);
#endif
}
/*! \brief yn() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_yn(int n, double x) {
#if Q_CC_MSVC
return _yn(n,x);
#else
return yn(n,x);
#endif
}
/** \brief calculate the distance between two QPointF points
* \ingroup jkqtptools_math_basic
@ -344,10 +426,10 @@ inline bool JKQTPIsOKFloat(T v) {
/** \brief evaluates a gaussian propability density function
* \ingroup jkqtptools_math_basic
*
* \f[ f(x,\mu, \sigma)=\frac{1}{\sqrt{2\pi\sigma^2}}\cdot\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)
* \f[ f(x,\mu, \sigma)=\frac{1}{\sqrt{2\pi\sigma^2}}\cdot\eJKQTPSTATISTICS_PIeft(-\frac{(x-\mu)^2}{2\sigma^2}\right)
*/
inline double jkqtp_gaussdist(double x, double mu=0.0, double sigma=1.0) {
return exp(-0.5*jkqtp_sqr(x-mu)/jkqtp_sqr(sigma))/sqrt(2.0*M_PI*sigma*sigma);
return exp(-0.5*jkqtp_sqr(x-mu)/jkqtp_sqr(sigma))/sqrt(2.0*JKQTPSTATISTICS_PI*sigma*sigma);
}
/*! \brief evaluate a polynomial \f$ f(x)=\sum\limits_{i=0}^Pp_ix^i \f$ with \f$ p_i \f$ taken from the range \a firstP ... \a lastP

View File

@ -28,7 +28,7 @@ double jkqtpstatKernel1DGaussian(double t) {
double jkqtpstatKernel1DCauchy(double t) {
return 1.0/(M_PI*(1.0+t*t));
return 1.0/(JKQTPSTATISTICS_PI*(1.0+t*t));
}
@ -71,13 +71,13 @@ double jkqtpstatKernel1DTricube(double t) {
double jkqtpstatKernel1DCosine(double t) {
return (fabs(t)<1.0)?(M_PI/4.0*cos(t*M_PI/2.0)):0.0;
return (fabs(t)<1.0)?(JKQTPSTATISTICS_PI/4.0*cos(t*JKQTPSTATISTICS_PI/2.0)):0.0;
}
double jkqtpstatKernel2DGaussian(double tx, double ty)
{
return exp(-0.5*(tx*tx+ty*ty))/(2.0*M_PI);
return exp(-0.5*(tx*tx+ty*ty))/(2.0*JKQTPSTATISTICS_PI);
}
double jkqtpstatKernel2DUniform(double tx, double ty) {

View File

@ -35,7 +35,7 @@
#include <iostream>
#include <QMutex>
#include <QGLWidget>
#include "jkqtcommon/jkqtpmathtools.h"
#ifdef DEBUG_TIMING
# include "jkqtcommon/jkqtphighrestimer.h"
#endif
@ -2067,7 +2067,7 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i
else if (r < 0.0)
r = 0.0;
double g = 255.0 * std::sin(M_PI*v);
double g = 255.0 * std::sin(JKQTPSTATISTICS_PI*v);
double b = 255.0 - 765.0 * v;
if (b < 0.0)
@ -2144,9 +2144,9 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i
if (r > 255.0)
r = 255.0;
double g = 255.0*sin(M_PI*v);
double g = 255.0*sin(JKQTPSTATISTICS_PI*v);
double b = 255.0*cos(0.5*M_PI*v);
double b = 255.0*cos(0.5*JKQTPSTATISTICS_PI*v);
lut_rainbow[l]=qRgb(static_cast<int>(r), static_cast<int>(g), static_cast<int>(b));
}
@ -2243,11 +2243,11 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i
if (r < 0.0) r = 0.0;
if (r > 1.0) r = 1.0;
double g = sin(M_PI/2.0*v);
double g = sin(JKQTPSTATISTICS_PI/2.0*v);
if (g < 0.0) g = 0.0;
if (g > 1.0) g = 1.0;
double b = cos(M_PI/2.0*v);
double b = cos(JKQTPSTATISTICS_PI/2.0*v);
if (b < 0.0) b = 0.0;
if (b > 1.0) b = 1.0;
@ -2292,7 +2292,7 @@ inline void JKQTFPimagePlot_array2image(T* dbl, int width, int height, QImage &i
if ((*plut)!=nullptr) {
for (size_t l=0; l<=JKQTFastPlotter::LUTSIZE; l++) {
double v=l/static_cast<double>(JKQTFastPlotter::LUTSIZE);
double r = (v < 0.5) ? 128.0*sin(M_PI*(2.0*v-0.5))+128.0 : 255.0;
double r = (v < 0.5) ? 128.0*sin(JKQTPSTATISTICS_PI*(2.0*v-0.5))+128.0 : 255.0;
if (r > 255.0)
r = 255.0;

View File

@ -1239,10 +1239,10 @@ void JKQTPVerticalAxis::drawTickLabel1(JKQTPEnhancedPainter &painter, double xx,
} else if (axisStyle.tickLabelAngle!=0) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
if (axisStyle.tickLabelAngle>0) {
painter.translate(lx-strikeoutPos+(width)*(1.0-cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)), yy+strikeoutPos-width*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI));
painter.translate(lx-strikeoutPos+(width)*(1.0-cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)), yy+strikeoutPos-width*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI));
painter.rotate(axisStyle.tickLabelAngle);
} else {
painter.translate(lx+strikeoutPos+(width-strikeoutPos)*(1.0-cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)), yy+strikeoutPos+width*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI));
painter.translate(lx+strikeoutPos+(width-strikeoutPos)*(1.0-cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)), yy+strikeoutPos+width*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI));
painter.rotate(axisStyle.tickLabelAngle);
}
getParentMathText()->draw(painter, 0,0);
@ -1281,7 +1281,7 @@ void JKQTPVerticalAxis::drawTickLabel2(JKQTPEnhancedPainter &painter, double xx,
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
double shiftx=0;
if (axisStyle.tickLabelAngle>0) {
shiftx=strikeoutPos*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI);
shiftx=strikeoutPos*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI);
} else {
}
@ -1832,10 +1832,10 @@ void JKQTPHorizontalAxis::drawTickLabel1(JKQTPEnhancedPainter &painter, double x
if (axisStyle.tickLabelAngle!=0) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
if (axisStyle.tickLabelAngle>0) {
painter.translate(xx-fabs(ascent*sin(axisStyle.tickLabelAngle/180.0*M_PI)/2.0), lx0+fabs(ascent*cos(axisStyle.tickLabelAngle/180.0*M_PI)));
painter.translate(xx-fabs(ascent*sin(axisStyle.tickLabelAngle/180.0*JKQTPSTATISTICS_PI)/2.0), lx0+fabs(ascent*cos(axisStyle.tickLabelAngle/180.0*JKQTPSTATISTICS_PI)));
painter.rotate(axisStyle.tickLabelAngle);
} else {
painter.translate(xx+fabs(ascent*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)/2.0)-width*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)), lx0+ascent*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI))+fabs(width*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)));
painter.translate(xx+fabs(ascent*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)/2.0)-width*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)), lx0+ascent*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI))+fabs(width*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)));
painter.rotate(axisStyle.tickLabelAngle);
}
getParentMathText()->draw(painter, 0,0);
@ -1862,10 +1862,10 @@ void JKQTPHorizontalAxis::drawTickLabel2(JKQTPEnhancedPainter &painter, double x
if (axisStyle.tickLabelAngle!=0) {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
if (axisStyle.tickLabelAngle>0) {
painter.translate(xx+fabs(descent*sin(axisStyle.tickLabelAngle/180.0*M_PI)/2.0), lx0-fabs(descent*cos(axisStyle.tickLabelAngle/180.0*M_PI)));
painter.translate(xx+fabs(descent*sin(axisStyle.tickLabelAngle/180.0*JKQTPSTATISTICS_PI)/2.0), lx0-fabs(descent*cos(axisStyle.tickLabelAngle/180.0*JKQTPSTATISTICS_PI)));
painter.rotate(-axisStyle.tickLabelAngle);
} else {
painter.translate(xx-fabs(descent*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)/2.0)-width*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)), lx0-descent*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*M_PI))-fabs(width*sin(fabs(axisStyle.tickLabelAngle)/180.0*M_PI)));
painter.translate(xx-fabs(descent*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)/2.0)-width*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)), lx0-descent*fabs(cos(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI))-fabs(width*sin(fabs(axisStyle.tickLabelAngle)/180.0*JKQTPSTATISTICS_PI)));
painter.rotate(-axisStyle.tickLabelAngle);
}
getParentMathText()->draw(painter, 0,0);

View File

@ -108,7 +108,7 @@ enum class JKQTPDatastoreItemFormat {
* QVector<double> X, Y;
* const int Ndata=100;
* for (int i=0; i<Ndata; i++) {
* * const double x=double(i)/double(Ndata)*8.0*M_PI;
* * const double x=double(i)/double(Ndata)*8.0*JKQTPSTATISTICS_PI;
* X<<x;
* Y<<sin(x);
* }
@ -790,7 +790,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{
* QVector<double> X, Y;
* const int Ndata=100;
* for (int i=0; i<Ndata; i++) {
* const double x=double(i)/double(Ndata)*8.0*M_PI;
* const double x=double(i)/double(Ndata)*8.0*JKQTPSTATISTICS_PI;
* X<<x;
* Y<<sin(x);
* }
@ -828,7 +828,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPDatastore{
* QVector<double> X, Y;
* const int Ndata=100;
* for (int i=0; i<Ndata; i++) {
* const double x=double(i)/double(Ndata)*8.0*M_PI;
* const double x=double(i)/double(Ndata)*8.0*JKQTPSTATISTICS_PI;
* X<<x;
* Y<<sin(x);
* }

View File

@ -516,7 +516,7 @@ void JKQTPlotter::paintUserAction() {
painter.drawLine(QPointF(x2,y1), QPointF(x2,y2));
painter.drawLine(QPointF(x1,y1), QPointF(x2,y2));
const double dxy=sqrt(jkqtp_sqr(mouseDragRectXEnd-mouseDragRectXStart)+jkqtp_sqr(mouseDragRectYEnd-mouseDragRectYStart));
const double alpha=atan2((mouseDragRectYEnd-mouseDragRectYStart), (mouseDragRectXEnd-mouseDragRectXStart))/M_PI*180.0;
const double alpha=atan2((mouseDragRectYEnd-mouseDragRectYStart), (mouseDragRectXEnd-mouseDragRectXStart))/JKQTPSTATISTICS_PI*180.0;
const double dx=fabs(mouseDragRectXEnd-mouseDragRectXStart);
const double dy=fabs(mouseDragRectYEnd-mouseDragRectYStart);