Commit 46c8f217 authored by Bill Lorensen's avatar Bill Lorensen

ENH: Consistent use of double precision pi in the toolkit.

For an analysis see:
http://itk.org/Wiki/VTK/VTK6/Migration/DoublePrecisionPi

1) vtkMath::Pi now returns double.
2) vtkMath::TwoPi() is replaced with 2.0 * vtkMath::Pi().
2) Remove vtkMath::DoublePi and vtkMath::DoubleTwoPi and mark them as
   deprecated.
3) Replace explicit use of 3.1415... and 6.28... with the vtkMath
   constants.

Change-Id: Ibc947ac4c16811294c0cc0cafd593834244d2925
parent b75cfc88
......@@ -13,6 +13,7 @@
=========================================================================*/
#include "vtkMath.h"
#include "vtkScatterPlotMatrix.h"
#include "vtkRenderWindow.h"
#include "vtkChart.h"
......@@ -53,7 +54,7 @@ int TestScatterPlotMatrix(int, char * [])
table->AddColumn(tangent.GetPointer());
// Test the chart scatter plot matrix
int numPoints = 100;
float inc = 4.0 * 3.14 / (numPoints-1);
float inc = 4.0 * vtkMath::Pi() / (numPoints-1);
table->SetNumberOfRows(numPoints);
for (int i = 0; i < numPoints; ++i)
{
......
......@@ -62,7 +62,7 @@ void vtkBoxMuellerRandomSequence::Next()
y=this->UniformSequence->GetValue();
}
this->Value=sqrt(-2.0*log(x))*cos(vtkMath::DoubleTwoPi()*y);
this->Value=sqrt(-2.0*log(x))*cos(2.0 * vtkMath::Pi()*y);
}
// ----------------------------------------------------------------------------
......
......@@ -204,19 +204,19 @@ void vtkLookupTable::ForceBuild()
case VTK_RAMP_SCURVE:
{
c_rgba[0] = static_cast<unsigned char>
(127.5*(1.0+cos((1.0-static_cast<double>(rgba[0]))*3.141593)));
(127.5*(1.0+cos((1.0-static_cast<double>(rgba[0]))*vtkMath::Pi())));
c_rgba[1] = static_cast<unsigned char>
(127.5*(1.0+cos((1.0-static_cast<double>(rgba[1]))*3.141593)));
(127.5*(1.0+cos((1.0-static_cast<double>(rgba[1]))*vtkMath::Pi())));
c_rgba[2] = static_cast<unsigned char>
(127.5*(1.0+cos((1.0-static_cast<double>(rgba[2]))*3.141593)));
(127.5*(1.0+cos((1.0-static_cast<double>(rgba[2]))*vtkMath::Pi())));
c_rgba[3] = static_cast<unsigned char> (alpha*255.0);
/* same code, but with rounding for correctness
c_rgba[0] = static_cast<unsigned char>
(127.5*(1.0 + cos((1.0 - rgba[0])*3.141593)) + 0.5);
(127.5*(1.0 + cos((1.0 - rgba[0])*vtkMath::Pi())) + 0.5);
c_rgba[1] = static_cast<unsigned char>
(127.5*(1.0 + cos((1.0 - rgba[1])*3.141593)) + 0.5);
(127.5*(1.0 + cos((1.0 - rgba[1])*vtkMath::Pi())) + 0.5);
c_rgba[2] = static_cast<unsigned char>
(127.5*(1.0 + cos((1.0 - rgba[2])*3.141593)) + 0.5);
(127.5*(1.0 + cos((1.0 - rgba[2])*vtkMath::Pi())) + 0.5);
c_rgba[3] = static_cast<unsigned char>(alpha*255.0 + 0.5);
*/
}
......
......@@ -2973,7 +2973,7 @@ int vtkMath::PointIsWithinBounds(double point[3], double bounds[6], double delta
//----------------------------------------------------------------------------
double vtkMath::GaussianAmplitude(const double variance, const double distanceFromMean)
{
return 1./(sqrt(2.*vtkMath::DoublePi() * variance)) * exp(-(pow(distanceFromMean,2))/(2.*variance));
return 1./(sqrt(2.*vtkMath::Pi() * variance)) * exp(-(pow(distanceFromMean,2))/(2.*variance));
}
//----------------------------------------------------------------------------
......
......@@ -75,18 +75,16 @@ public:
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// A mathematical constant. This version is 3.14159265358979f.
static float Pi() { return 3.14159265358979f; };
// A mathematical constant. This version is atan(1.0) * 4.0
static double Pi() { return 3.141592653589793; };
// Description:
// A mathematical constant (double-precision version). This version
// is 6.283185307179586.
static double DoubleTwoPi() { return 6.283185307179586; };
// Deprecated. Use vtkMath::Pi() instead.
VTK_LEGACY(static double DoublePi());
// Description:
// A mathematical constant (double-precision version). This version
// is 3.1415926535897932384626.
static double DoublePi() { return 3.1415926535897932384626; };
// Deprecated. Use vtkMath::TwoPi() instead.
VTK_LEGACY(static double DoubleTwoPi());
// Description:
// Convert degrees into radians
......
......@@ -2005,8 +2005,8 @@ int vtkPolynomialSolversUnivariate::SolveCubic( double c0, double c1, double c2,
theta = acos( R / (sqrt(Q_cubed) ) );
*r1 = -2.0*sqrt(Q)*cos( theta/3.0 ) - c1/3.0;
*r2 = -2.0*sqrt(Q)*cos( (theta + 2.0*3.141592653589)/3.0) - c1/3.0;
*r3 = -2.0*sqrt(Q)*cos( (theta - 2.0*3.141592653589)/3.0) - c1/3.0;
*r2 = -2.0*sqrt(Q)*cos( (theta + 2.0 * vtkMath::Pi())/3.0) - c1/3.0;
*r3 = -2.0*sqrt(Q)*cos( (theta - 2.0 * vtkMath::Pi())/3.0) - c1/3.0;
*num_roots = 3;
......
......@@ -102,7 +102,7 @@ void vtkRectangularToCylindrical(const T inPoint[3], T outPoint[3])
else
{
// Change range to [0, 2*Pi], otherwise the same as atan2(y, x)
outPoint[1] = T(vtkMath::DoublePi()) + atan2(-y, -x);
outPoint[1] = T(vtkMath::Pi()) + atan2(-y, -x);
}
outPoint[2] = z;
}
......
......@@ -112,7 +112,7 @@ void vtkRectangularToSpherical(const T inPoint[3], T outPoint[3])
else
{
// Change range to [0, 2*Pi], otherwise the same as atan2(y, x)
outPoint[2] = T(vtkMath::DoublePi()) + atan2(-y, -x);
outPoint[2] = T(vtkMath::Pi()) + atan2(-y, -x);
}
}
......
......@@ -1433,7 +1433,7 @@ vtkAbstractTransform * vtkDelaunay2D::ComputeBestFittingPlane(
vtkMath::Normalize(rotationAxis);
const double rotationAngle =
180.0*acos(vtkMath::Dot(zaxis,normal))/3.1415926;
180.0*acos(vtkMath::Dot(zaxis,normal))/vtkMath::Pi();
transform->PreMultiply();
transform->Identity();
......
......@@ -151,8 +151,8 @@ void vtkLinkEdgels::LinkEdgels(int xdim, int ydim, double *image,
}
zpos = z*xdim*ydim;
linkThresh = cos(this->LinkThreshold*3.1415926/180.0);
phiThresh = cos(this->PhiThreshold*3.1415926/180.0);
linkThresh = cos(this->LinkThreshold*vtkMath::Pi()/180.0);
phiThresh = cos(this->PhiThreshold*vtkMath::Pi()/180.0);
// first find all forward & backwards links
for (y = 0; y < ydim; y++)
......
......@@ -36,19 +36,19 @@ vtkStandardNewMacro(vtkTimeSourceExample);
//----------------------------------------------------------------------------
double vtkTimeSourceExample::ValueFunction(double t)
{
return sin(2*vtkMath::DoublePi()*t);
return sin(2*vtkMath::Pi()*t);
}
//----------------------------------------------------------------------------
double vtkTimeSourceExample::XFunction(double t)
{
return sin(2*vtkMath::DoublePi()*t)*this->XAmplitude;
return sin(2*vtkMath::Pi()*t)*this->XAmplitude;
}
//----------------------------------------------------------------------------
double vtkTimeSourceExample::YFunction(double t)
{
return sin(2*vtkMath::DoublePi()*t)*this->YAmplitude;
return sin(2*vtkMath::Pi()*t)*this->YAmplitude;
}
//----------------------------------------------------------------------------
......
......@@ -2303,7 +2303,7 @@ namespace vtkYoungsMaterialInterfaceCellCutInternals
#ifndef M_PI
#define M_PI 3.14159265358979323846
#define M_PI vtkMath::Pi()
#endif
/**************************************
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkRenderLargeImage.h"
#include "vtkMath.h"
#include "vtkCamera.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
......@@ -224,8 +225,8 @@ void vtkRenderLargeImage::RequestData(
viewAngle = cam->GetViewAngle();
parallelScale = cam->GetParallelScale();
cam->SetViewAngle(atan(tan(viewAngle*3.1415926/360.0)/this->Magnification)
* 360.0 / 3.1415926);
cam->SetViewAngle(atan(tan(viewAngle*vtkMath::Pi()/360.0)/this->Magnification)
* 360.0 / vtkMath::Pi());
cam->SetParallelScale(parallelScale/this->Magnification);
// are we double buffering? If so, read from back buffer ....
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkButterflySubdivisionFilter.h"
#include "vtkMath.h"
#include "vtkCellArray.h"
#include "vtkEdgeTable.h"
#include "vtkIdList.h"
......@@ -215,7 +216,7 @@ void vtkButterflySubdivisionFilter::GenerateLoopStencil(
}
// Generate weights
#define VTK_PI 3.14159265358979
#define VTK_PI vtkMath::Pi()
int K = stencilIds->GetNumberOfIds();
if (K >= 5)
{
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkLoopSubdivisionFilter.h"
#include "vtkMath.h"
#include "vtkCell.h"
#include "vtkCellArray.h"
#include "vtkEdgeTable.h"
......@@ -236,7 +237,7 @@ void vtkLoopSubdivisionFilter::GenerateEvenStencil (vtkIdType p1,
if (K > 3)
{
// Generate weights
#define VTK_PI 3.14159265358979
#define VTK_PI vtkMath::Pi()
cosSQ = .375 + .25 * cos (2.0 * VTK_PI / (double) K);
cosSQ = cosSQ * cosSQ;
beta = (.625 - cosSQ) / (double) K;
......
......@@ -72,8 +72,8 @@ int main( int argc, char* argv[] )
double stepSize(0.01);
double radius = 0.8;
double scale = 1;
double maximumPropagation = radius*scale*2*3.14;
double angle = 3.14/20;
double maximumPropagation = radius*scale*2*vtkMath::Pi();
double angle = vtkPath::Pi()/20;
int numTraces=1;
vtkNew<vtkPStreamTracer> tracer;
......
......@@ -150,7 +150,7 @@ int vtkArcSource::RequestData( vtkInformation* vtkNotUsed(request),
angle = acos( dotprod );
if ( this->Negative )
{
angle -= vtkMath::DoubleTwoPi();
angle -= (2.0 * vtkMath::Pi());
}
// Calcute radius
......
......@@ -101,7 +101,7 @@ int vtkConeSource::RequestData(
if ( this->Resolution )
{
angle = 2.0*3.141592654/this->Resolution;
angle = 2.0 * vtkMath::Pi()/this->Resolution;
}
else
{
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkCylinderSource.h"
#include "vtkMath.h"
#include "vtkCellArray.h"
#include "vtkFloatArray.h"
#include "vtkInformation.h"
......@@ -50,7 +51,7 @@ int vtkCylinderSource::RequestData(
vtkPolyData *output = vtkPolyData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
double angle= 2.0*3.141592654/this->Resolution;
double angle= 2.0 * vtkMath::Pi()/this->Resolution;
int numPolys, numPts;
double xbot[3], tcbot[2], nbot[3];
double xtop[3], tctop[2], ntop[3];
......
......@@ -76,7 +76,7 @@ int vtkPointSource::RequestData(
cosphi = 1 - 2*vtkMath::Random();
sinphi = sqrt(1 - cosphi*cosphi);
radius = this->Radius * sinphi;
theta = 6.2831853 * vtkMath::Random();
theta = 2.0 * vtkMath::Pi() * vtkMath::Random();
x[0] = this->Center[0] + radius*cos(theta);
x[1] = this->Center[1] + radius*sin(theta);
x[2] = this->Center[2] + this->Radius*cosphi;
......@@ -91,7 +91,7 @@ int vtkPointSource::RequestData(
sinphi = sqrt(1 - cosphi*cosphi);
rho = this->Radius*pow(vtkMath::Random(),0.33333333);
radius = rho * sinphi;
theta = 6.2831853 * vtkMath::Random();
theta = 2.0 * vtkMath::Pi() * vtkMath::Random();
x[0] = this->Center[0] + radius*cos(theta);
x[1] = this->Center[1] + radius*sin(theta);
x[2] = this->Center[2] + rho*cosphi;
......
......@@ -153,7 +153,7 @@ int vtkRegularPolygonSource::RequestData(
vtkMath::Cross(px,n,py); //created two orthogonal axes in the polygon plane, px & py
// Now run around normal vector to produce polygon points.
double theta = 2.0 * vtkMath::DoublePi() / numPts;
double theta = 2.0 * vtkMath::Pi() / numPts;
for (j=0; j<numPts; j++)
{
for (i=0; i<3; i++)
......
......@@ -393,7 +393,14 @@ static double cf(double w, double m, double a = 0)
double c;
double sgn;
c = cos(w);
if (w == vtkMath::Pi() || w == -vtkMath::Pi())
{
c = -1.0;
}
else
{
c = cos(w);
}
sgn = c < 0.0 ? -1.0 : 1.0;
return a + sgn*pow(sgn*c, m);
}
......@@ -403,7 +410,14 @@ static double sf(double w, double m)
double s;
double sgn;
s = sin(w);
if (w == vtkMath::Pi() || w == -vtkMath::Pi())
{
s = 0.0;
}
else
{
s = sin(w);
}
sgn = s < 0.0 ? -1.0 : 1.0;
return sgn*pow(sgn*s, m);
}
......
......@@ -48,7 +48,7 @@ int vtkTexturedSphereSource::RequestData(
// get the info object
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the ouptut
// get the output
vtkPolyData *output = vtkPolyData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
......@@ -90,7 +90,7 @@ int vtkTexturedSphereSource::RequestData(
for (i=0; i <= this->ThetaResolution; i++)
{
theta = i * deltaTheta;
tc[0] = theta/(2.0*3.1415926);
tc[0] = 2.0 * theta/vtkMath::Pi();
for (j=0; j <= this->PhiResolution; j++)
{
phi = j * deltaPhi;
......@@ -107,7 +107,7 @@ int vtkTexturedSphereSource::RequestData(
x[0] /= norm; x[1] /= norm; x[2] /= norm;
newNormals->InsertNextTuple(x);
tc[1] = 1.0 - phi/3.1415926;
tc[1] = 1.0 - phi/vtkMath::Pi();
newTCoords->InsertNextTuple(tc);
}
}
......
......@@ -377,7 +377,7 @@ int TestAutoCorrelativeStatistics( int, char *[] )
// Fill data columns
vtkIdType midPoint = cardTotal >> 1;
double dAlpha = vtkMath::DoubleTwoPi() / cardSlice;
double dAlpha = (2.0 * vtkMath::Pi()) / cardSlice;
for ( int i = 0; i < cardTotal; ++ i )
{
lineArr->InsertNextValue( i );
......
......@@ -754,7 +754,7 @@ bool vtkMultiCorrelativeAssessFunctor::Initialize( vtkTable* inData,
}
else
{
this->Normalization = sqrt( 3.141592653589793 ) / ( 1 << ( m / 2 ) );
this->Normalization = sqrt( vtkMath::Pi() ) / ( 1 << ( m / 2 ) );
for ( i = m - 2; i > 1; i -= 2 )
{
this->Normalization *= i;
......
......@@ -2466,7 +2466,7 @@ vtkDataArray* vtkExodusIIReaderPrivate::GetCacheOrRead( vtkExodusIICacheKey key
{
double* dispVal = displ->GetTuple( idx );
for ( c = 0; c < dim; ++c )
coords[c] += dispVal[c] * this->DisplacementMagnitude * cos( 2. * vtkMath::DoublePi() * this->ModeShapeTime );
coords[c] += dispVal[c] * this->DisplacementMagnitude * cos( 2. * vtkMath::Pi() * this->ModeShapeTime );
coords += 3;
}
......
......@@ -128,7 +128,7 @@ void vtkIVExporter::WriteData()
// this assumes the aspect ratio is 1
fprintf(fp,"%sPerspectiveCamera\n%s{\n%s heightAngle %f\n",
indent, indent, indent,
cam->GetViewAngle()*3.1415926/180.0);
cam->GetViewAngle()*vtkMath::Pi()/180.0);
}
VTK_INDENT_MORE;
fprintf(fp,"%snearDistance %f\n",indent, cam->GetClippingRange()[0]);
......@@ -138,7 +138,7 @@ void vtkIVExporter::WriteData()
cam->GetPosition()[1], cam->GetPosition()[2]);
tempd = cam->GetOrientationWXYZ();
fprintf(fp,"%sorientation %g %g %g %g\n%s}\n", indent,
tempd[1], tempd[2], tempd[3], tempd[0]*3.1415926/180.0, indent);
tempd[1], tempd[2], tempd[3], tempd[0]*vtkMath::Pi()/180.0, indent);
VTK_INDENT_LESS;
// do the lights first the ambient then the others
......@@ -278,7 +278,7 @@ void vtkIVExporter::WriteAnActor(vtkActor *anActor, FILE *fp)
fprintf(fp,"%stranslation %g %g %g\n", indent, tempd[0], tempd[1], tempd[2]);
tempd = trans->GetOrientationWXYZ();
fprintf(fp,"%srotation %g %g %g %g\n", indent, tempd[1], tempd[2],
tempd[3], tempd[0]*3.1415926/180.0);
tempd[3], tempd[0]*vtkMath::Pi()/180.0);
tempd = trans->GetScale();
fprintf(fp,"%sscaleFactor %g %g %g\n", indent, tempd[0], tempd[1], tempd[2]);
fprintf(fp,"%s}\n", indent);
......
......@@ -133,13 +133,13 @@ void vtkVRMLExporter::WriteData()
// do the camera
cam = ren->GetActiveCamera();
fprintf(fp," Viewpoint\n {\n fieldOfView %f\n",
cam->GetViewAngle()*3.1415926/180.0);
cam->GetViewAngle()*vtkMath::Pi()/180.0);
fprintf(fp," position %f %f %f\n",cam->GetPosition()[0],
cam->GetPosition()[1], cam->GetPosition()[2]);
fprintf(fp," description \"Default View\"\n");
tempd = cam->GetOrientationWXYZ();
fprintf(fp," orientation %g %g %g %g\n }\n", tempd[1], tempd[2],
tempd[3], tempd[0]*3.1415926/180.0);
tempd[3], tempd[0]*vtkMath::Pi()/180.0);
// do the lights first the ambient then the others
fprintf(fp,
......@@ -272,7 +272,7 @@ void vtkVRMLExporter::WriteAnActor(vtkActor *anActor, FILE *fp)
fprintf(fp," translation %g %g %g\n", tempd[0], tempd[1], tempd[2]);
tempd = trans->GetOrientationWXYZ();
fprintf(fp," rotation %g %g %g %g\n", tempd[1], tempd[2],
tempd[3], tempd[0]*3.1415926/180.0);
tempd[3], tempd[0]*vtkMath::Pi()/180.0);
tempd = trans->GetScale();
fprintf(fp," scale %g %g %g\n", tempd[0], tempd[1], tempd[2]);
fprintf(fp," children [\n");
......
......@@ -494,7 +494,7 @@ int vtkMNIObjectWriter::WriteNormals(vtkPolyData *data)
}
else if (dotprod <= -1.0)
{
angle = vtkMath::DoublePi();
angle = vtkMath::Pi();
}
else
{
......
......@@ -665,7 +665,7 @@ void vtkMPASReader::SetDefaults() {
this->IncludeTopography = false;
this->DoBugFix = false;
this->CenterRad = CenterLon * vtkMath::DoublePi() / 180.0;
this->CenterRad = CenterLon * vtkMath::Pi() / 180.0;
this->PointX = NULL;
this->PointY = NULL;
......@@ -1120,7 +1120,7 @@ void vtkMPASReader::ShiftLonData()
// need to shift over the point so center is at PI
if (this->PointX[j] < 0)
{
this->PointX[j] += 2*vtkMath::DoublePi();
this->PointX[j] += 2*vtkMath::Pi();
}
}
}
......@@ -1130,18 +1130,18 @@ void vtkMPASReader::ShiftLonData()
for (int j = this->PointOffset; j < this->NumberOfPoints + this->PointOffset; j++)
{
// need to shift over the point if centerLon dictates
if (this->CenterRad < vtkMath::DoublePi())
if (this->CenterRad < vtkMath::Pi())
{
if (this->PointX[j] > (this->CenterRad + vtkMath::DoublePi()))
if (this->PointX[j] > (this->CenterRad + vtkMath::Pi()))
{
this->PointX[j] = -((2*vtkMath::DoublePi()) - this->PointX[j]);
this->PointX[j] = -((2*vtkMath::Pi()) - this->PointX[j]);
}
}
else if (this->CenterRad > vtkMath::DoublePi())
else if (this->CenterRad > vtkMath::Pi())
{
if (this->PointX[j] < (this->CenterRad - vtkMath::DoublePi()))
if (this->PointX[j] < (this->CenterRad - vtkMath::Pi()))
{
this->PointX[j] += 2*vtkMath::DoublePi();
this->PointX[j] += 2*vtkMath::Pi();
}
}
}
......@@ -1164,12 +1164,12 @@ int vtkMPASReader::AddMirrorPoint(int index, double dividerX)
// add on east
if (X < dividerX)
{
X += 2*vtkMath::DoublePi();
X += 2*vtkMath::Pi();
}
else
{
// add on west
X -= 2*vtkMath::DoublePi();
X -= 2*vtkMath::Pi();
}
this->PointX[this->CurrentExtraPoint] = X;
......@@ -1410,8 +1410,8 @@ void vtkMPASReader::OutputPoints(bool init)
if (ProjectLatLon)
{
x = this->PointX[j] * 180.0 / vtkMath::DoublePi();
y = this->PointY[j] * 180.0 / vtkMath::DoublePi();
x = this->PointX[j] * 180.0 / vtkMath::Pi();
y = this->PointY[j] * 180.0 / vtkMath::Pi();
z = 0.0;
}
else
......@@ -2221,7 +2221,7 @@ void vtkMPASReader::SetCenterLon(int val)
{
vtkDebugMacro( << "SetCenterLon: set to " << CenterLon << endl);
CenterLon = val;
this->CenterRad = CenterLon * vtkMath::DoublePi() / 180.0;
this->CenterRad = CenterLon * vtkMath::Pi() / 180.0;
vtkDebugMacro( << "this->CenterRad set to " << this->CenterRad << endl);
if (ProjectLatLon)
{
......
......@@ -773,7 +773,7 @@ int vtkSLACReader::RequestData(vtkInformation *request,
if (this->FrequencyModes)
{
this->Phase = vtkMath::DoubleTwoPi()*(time*this->Frequency);
this->Phase = 2.0 * vtkMath::Pi()*(time*this->Frequency);
}
int readMesh = !this->MeshUpToDate();
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkImageRGBToHSI.h"
#include "vtkMath.h"
#include "vtkImageData.h"
#include "vtkImageProgressIterator.h"
#include "vtkObjectFactory.h"
......@@ -92,11 +93,11 @@ void vtkImageRGBToHSIExecute(vtkImageRGBToHSI *self,
}
if (G >= B)
{
H = max * (temp / 6.2831853);
H = max * (temp / (2.0 * vtkMath::Pi()));
}
else
{
H = max * (1.0 - (temp / 6.2831853));
H = max * (1.0 - (temp / (2.0 * vtkMath::Pi())));
}
// assign output.
......
......@@ -423,7 +423,7 @@ namespace {
// the code that uses it never evaluates it at x=0)
inline double vtkSincPi(double x)
{
x *= vtkMath::DoublePi();
x *= vtkMath::Pi();
return sin(x)/x;
}
......@@ -465,7 +465,7 @@ double vtkSincWindow::Lanczos(double x)
double vtkSincWindow::Kaiser(double x, double a)
{
double api = a*vtkMath::DoublePi();
double api = a*vtkMath::Pi();
double y = 1 - x*x;
y *= (y > 0); // if less than zero, set to zero
......@@ -474,7 +474,7 @@ double vtkSincWindow::Kaiser(double x, double a)
double vtkSincWindow::Cosine(double x)
{
double halfpi = 0.5*vtkMath::DoublePi();
double halfpi = 0.5*vtkMath::Pi();
return cos(x*halfpi);
}
......@@ -484,7 +484,7 @@ double vtkSincWindow::Hamming(double x, const double *a)
{
double q = 0;
double y = a[0];
x *= vtkMath::DoublePi();
x *= vtkMath::Pi();
for (int i = 1; i < N; i++)
{
q += x;
......
......@@ -14,10 +14,9 @@
=========================================================================*/
#include "vtkImageFourierFilter.h"
#include "vtkMath.h"
#include <math.h>
/*=========================================================================
Vectors of complex numbers.
=========================================================================*/
......@@ -61,7 +60,7 @@ void vtkImageFourierFilter::ExecuteFftStep2(vtkImageComplex *p_in,
fact1.Real = 1.0;
fact1.Imag = 0.0;
q.Real = 0.0;
q.Imag = -2.0 * 3.141592654 * static_cast<float>(fb)
q.Imag = -(2.0 * vtkMath::Pi()) * static_cast<float>(fb)
/ static_cast<float>(bsize * 2);
vtkImageComplexExponential(q, q);
p3 = p_out;
......@@ -117,7 +116,7 @@ void vtkImageFourierFilter::ExecuteFftStepN(vtkImageComplex *p_in,
for(i0 = 0; i0 < n; ++i0)
{
q.Real = 0.0;
q.Imag = -2.0 * 3.141592654 * static_cast<float>(i0) *
q.Imag = -(2.0 * vtkMath::Pi()) * static_cast<float>(i0) *
static_cast<float>(fb) / static_cast<float>(bsize*n);
vtkImageComplexExponential(q, q);
p3 = p_out;
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkImageEuclideanToPolar.h"
#include "vtkMath.h"
#include "vtkImageData.h"
#include "vtkImageProgressIterator.h"
#include "vtkObjectFactory.h"
......@@ -65,7 +66,7 @@ void vtkImageEuclideanToPolarExecute(vtkImageEuclideanToPolar *self,
}
else
{
Theta = atan2(Y, X) * thetaMax / 6.2831853;
Theta = atan2(Y, X) * thetaMax / (2.0 * vtkMath::Pi());
if (Theta < 0.0)
{
Theta += thetaMax;
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkImageCanvasSource2D.h"
#include "vtkMath.h"
#include "vtkImageCast.h"
#include "vtkImageClip.h"
#include "vtkInformation.h"
......@@ -722,7 +723,7 @@ void vtkImageCanvasSource2DDrawCircle(vtkImageData *image,
z = (z > max2) ? max2 : z;
maxV = image->GetNumberOfScalarComponents() - 1;
numberOfSteps = static_cast<int>(ceil(6.2831853 * radius));
numberOfSteps = static_cast<int>(ceil(2.0 * vtkMath::Pi() * radius));
thetaCos = cos(1.0 / radius);
thetaSin = sin(1.0 / radius);
x = radius;
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkImageSinusoidSource.h"
#include "vtkMath.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
......@@ -192,7 +193,7 @@ void vtkImageSinusoidSource::ExecuteDataWithInformation(vtkDataObject *output,
sum = zContrib + yContrib + xContrib;
*outPtr = this->Amplitude *
cos((6.2831853 * sum / this->Period) - this->Phase);
cos((2.0 * vtkMath::Pi() * sum / this->Period) - this->Phase);
outPtr++;
}
outPtr += outIncY;
......
......@@ -55,7 +55,7 @@ public:
{
// Circles will not fit in another of radius Re.
// Return how much to increment Re so that they will.
this->Alpha = neighbor.Alpha + vtkMath::DoublePi();
this->Alpha = neighbor.Alpha + vtkMath::Pi();