Commit 8312faad authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] removed all occurrences of piDouble/piFloat. Still keeping piFloat...

[CHANGE] removed all occurrences of piDouble/piFloat. Still keeping piFloat and piDouble defines in WMath though.
parent 068d96eb
......@@ -160,7 +160,7 @@ namespace
{
double calcAreaScale( const double bucket, const size_t j )
{
double theta = piDouble - ( j * bucket + ( bucket / 2.0 ) );
double theta = pi() - ( j * bucket + ( bucket / 2.0 ) );
return 1.0 / sin( theta );
}
}
......@@ -171,7 +171,7 @@ WGETexture2D::RPtr WHistogram2D::getSphereTexture()
size_t imageWidth = m_buckets[0];
size_t imageHeight = m_buckets[1];
double maxCount = 0.0;
const double bucket = piDouble / static_cast< double >( imageHeight );
const double bucket = pi() / static_cast< double >( imageHeight );
double areaScale = 0.0;
for( size_t j = 0; j < imageHeight; ++j ) // get max bin for scaling
......
......@@ -42,7 +42,8 @@
*
* \tparam T the desired type
* \param T the parameter is only needed for deducing T. This is needed since C++ < C++11 does not allow default template types in function templates.
* You need to set this parameter to an example value of the desired type T for pi. Usually, the default constructor will do well.
* You need to set this parameter to an example value of the desired type T for pi. Usually, the default constructor will do well. The default is
* double, so calling pi() without arguments returns a pi as double.
*
* \example pi( int() ) will return 3.
*
......@@ -55,10 +56,10 @@ T pi( T = double() )
}
/**
* For the lazy programmer and backwards compatibility, define piDouble to be PI as double. Since defines are usually a bad idea (for aliasing), you
* For the lazy programmer and backwards compatibility, define pi() to be PI as double. Since defines are usually a bad idea (for aliasing), you
* should avoid using this. Use the \ref pi function directly.
*/
#define piDouble pi( double() )
#define pi() pi( double() )
/**
* For the lazy programmer and backwards compatibility, define piFloat to be PI as float. Since defines are usually a bad idea (for aliasing), you
......
......@@ -590,7 +590,7 @@ WMatrix< T > WSymmetricSphericalHarmonic< T >::getSHFittingMatrixForConstantSoli
wlog::debug( "" ) << "P*result: " << result;
// correction factor
T correctionFactor = 1.0 / ( 16.0 * std::pow( static_cast< T >( piDouble ), 2 ) );
T correctionFactor = 1.0 / ( 16.0 * std::pow( static_cast< T >( pi() ), 2 ) );
result *= correctionFactor;
return result;
......@@ -712,7 +712,7 @@ WMatrix< T > WSymmetricSphericalHarmonic< T >::calcFRTMatrix( size_t order )
WMatrix< T > result( R, R );
for( size_t k = 0; k <= order; k += 2 )
{
T h = 2.0 * static_cast< T >( piDouble ) * static_cast< T >( std::pow( static_cast< T >( -1 ), static_cast< T >( k / 2 ) ) ) *
T h = 2.0 * static_cast< T >( pi() ) * static_cast< T >( std::pow( static_cast< T >( -1 ), static_cast< T >( k / 2 ) ) ) *
static_cast< T >( oddFactorial( ( k <= 1 ) ? 1 : k - 1 ) ) / static_cast< T >( evenFactorial( k ) );
for( int m = -static_cast< int >( k ); m <= static_cast< int >( k ); ++m )
{
......@@ -804,7 +804,7 @@ void WSymmetricSphericalHarmonic< T >::normalize()
T scale = 0.0;
if( m_SHCoefficients.size() > 0 )
{
scale = std::sqrt( 4.0 * static_cast< T >( piDouble ) ) * m_SHCoefficients[0];
scale = std::sqrt( 4.0 * static_cast< T >( pi() ) ) * m_SHCoefficients[0];
}
for( size_t i = 0; i < m_SHCoefficients.size(); i++ )
{
......
......@@ -65,14 +65,14 @@ public:
reference.setZero();
// j 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
// lj 0 2 2 2 2 2 4 4 4 4 4 4 4 4 4
reference( 0, 0 ) = 2.0 * piDouble;
reference( 0, 0 ) = 2.0 * pi();
for( size_t i = 1; i <= 5; i++ )
{
reference( i, i ) = -2.0 * piDouble * 1.0 / 2.0;
reference( i, i ) = -2.0 * pi() * 1.0 / 2.0;
}
for( size_t i = 6; i <= 14; i++ )
{
reference( i, i ) = 2.0 * piDouble * 3.0 / 8.0;
reference( i, i ) = 2.0 * pi() * 3.0 / 8.0;
}
for( size_t i = 0; i < 15; ++i )
......
......@@ -790,11 +790,11 @@ osg::ref_ptr< osg::Group > wge::creatCoordinateSystem(
osg::Matrixd matrixTranslateFrom0 = osg::Matrixd::translate( middle.x(), middle.y(), middle.z() );
graphXTransform->setMatrix( matrixTranslateTo0 * osg::Matrixd::rotate(
90.0 * piDouble / 180.0,
90.0 * pi() / 180.0,
osg::Vec3f( 0.0, 1.0, 0.0 ) ) * matrixTranslateFrom0
);
graphYTransform->setMatrix( matrixTranslateTo0 * osg::Matrixd::rotate(
-90.0 * piDouble / 180.0,
-90.0 * pi() / 180.0,
osg::Vec3f( 1.0, 0.0, 0.0 ) ) * matrixTranslateFrom0
);
......
......@@ -878,7 +878,7 @@ osg::Vec3 WTriangleMesh::estimateSmoothedVertexPosition( std::size_t vtx, float
// calc f
double dist = ( m_verts->operator[] ( vtx ) - center ).length();
double f = 1.0 / ( sigmaDistance * sqrt( 2.0 * piDouble ) ) * exp( -0.5 * dist * dist );
double f = 1.0 / ( sigmaDistance * sqrt( 2.0 * pi() ) ) * exp( -0.5 * dist * dist );
double g;
if( !mollify )
......@@ -890,7 +890,7 @@ osg::Vec3 WTriangleMesh::estimateSmoothedVertexPosition( std::size_t vtx, float
dist = ( p - pred ).length();
}
g = 1.0 / ( sigmaInfluence * sqrt( 2.0 * piDouble ) ) * exp( -0.5 * dist * dist );
g = 1.0 / ( sigmaInfluence * sqrt( 2.0 * pi() ) ) * exp( -0.5 * dist * dist );
sum += area * f * g;
res += center * area * f * g;
......
......@@ -111,12 +111,12 @@ void WGEAnimationManipulator::setTimer( WTimer::ConstSPtr timer )
double degToRad( double deg )
{
return deg * ( piDouble / 180.0 );
return deg * ( pi() / 180.0 );
}
double radToDeg( double rad )
{
return rad * ( 180.0 / piDouble );
return rad * ( 180.0 / pi() );
}
template < typename T >
......@@ -161,7 +161,7 @@ double smooth( double value, double min, double max )
}
double scaledValue = ( value - min ) / max;
return min + max * ( 0.5 * ( 1.0 + cos( piDouble + ( scaledValue * piDouble ) ) ) );
return min + max * ( 0.5 * ( 1.0 + cos( pi() + ( scaledValue * piDouble ) ) ) );
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -335,8 +335,8 @@ void WGEAnimationManipulator::handleFrame()
// this brings the BBox to the center, makes it larger and rotates the front towards the camera
osg::Matrixd mBBTranslate = osg::Matrixd::translate( -159.0 / 2.0, -199.0 / 2.0, -159.0 / 2.0 );
osg::Matrixd mBBScale = osg::Matrixd::scale( 1.5, 1.5, 1.5 );
osg::Matrixd mBBRotate = osg::Matrixd::rotate( -piDouble / 2.0, 1.0, 0.0, 0.0 ) *
osg::Matrixd::rotate( piDouble, 0.0, 1.0, 0.0 );
osg::Matrixd mBBRotate = osg::Matrixd::rotate( -pi() / 2.0, 1.0, 0.0, 0.0 ) *
osg::Matrixd::rotate( pi(), 0.0, 1.0, 0.0 );
// Scene 1:
// construct the animation here.
Rotator rotateToBack = Rotator( elapsed, 0.0, Transformation::axeY, 360.0, 22.5 );
......@@ -360,8 +360,8 @@ void WGEAnimationManipulator::handleFrame()
// this brings the BBox to the center, makes it larger and rotates the front towards the camera
// osg::Matrixd mBBTranslate = osg::Matrixd::translate( -159.0 / 2.0, -199.0 / 2.0, -179.0 / 2.0 );
// osg::Matrixd mBBScale = osg::Matrixd::scale( 2.0, 2.0, 2.0 );
// osg::Matrixd mBBRotate = osg::Matrixd::rotate( -piDouble / 2.0, 1.0, 0.0, 0.0 ) *
// osg::Matrixd::rotate( piDouble, 0.0, 1.0, 0.0 );
// osg::Matrixd mBBRotate = osg::Matrixd::rotate( -pi() / 2.0, 1.0, 0.0, 0.0 ) *
// osg::Matrixd::rotate( pi(), 0.0, 1.0, 0.0 );
// Transformation rotateToBack = Rotator( elapsed, 0.0, Transformation::axeY, 360.0, 22.5 );
// Transformation translateABitUp = Translator( elapsed, rotateToBack.finish() - 5.0, Transformation::axeY * -45.0, 0.25 );
// Transformation zoomNei = Zoomer( elapsed, rotateToBack.finish() - 5.0, 2.00, 0.25 );
......
......@@ -316,12 +316,12 @@ void WSphericalHarmonicsCoefficientsThread< T >::threadMain()
double scale = 1.0;
if( m_parameter.m_normalize )
{
scale *= std::sqrt( 4.0 * piDouble ) / coefficients[ 0 ];
scale *= std::sqrt( 4.0 * pi() ) / coefficients[ 0 ];
}
if( m_parameter.m_csa )
{
coefficients[ 0 ] = 1.0 / ( 2.0 * std::sqrt( piDouble ) );
coefficients[ 0 ] = 1.0 / ( 2.0 * std::sqrt( pi() ) );
}
for( std::size_t j = 0; j < l; j++ )
......
......@@ -76,8 +76,8 @@ void WDataCreatorFiberSpiral::operator()( WProgress::SPtr progress,
double a1 = static_cast< double >( std::rand() % 255 ) / 255.0; // NOLINT - rand_r has portability issues.
double a2 = static_cast< double >( std::rand() % 255 ) / 255.0; // NOLINT - rand_r has portability issues.
double seedX = cos( 2.0 * piDouble * a1 ) * tubeRadius;
double seedY = sin( 2.0 * piDouble * a2 ) * tubeRadius;
double seedX = cos( 2.0 * pi() * a1 ) * tubeRadius;
double seedY = sin( 2.0 * pi() * a2 ) * tubeRadius;
double seedZ = sqrt( tubeRadius - ( seedX * seedX ) - ( seedY * seedY ) );
WPosition seed( seedX, seedY, seedZ );
......@@ -85,7 +85,7 @@ void WDataCreatorFiberSpiral::operator()( WProgress::SPtr progress,
for( size_t vidx = 0; vidx < numVertsPerFiber; ++vidx )
{
double v = static_cast< double >( vidx ) / static_cast< double >( numVertsPerFiber - 1 );
double degree = v * 2.0 * piDouble * numRotations;
double degree = v * 2.0 * pi() * numRotations;
double X = seed.x() + cos( degree ) * v * spiralRadius;
double Y = seed.y() + sin( degree ) * v * spiralRadius;
......
......@@ -34,7 +34,7 @@ WManipulatorRotation::WManipulatorRotation()
m_axis = m_properties->addProperty( "Rotation axis", "Axis to rotate around in world coordinates.", WPosition( 0.0, 0.0, 1.0 ) );
m_angle = m_properties->addProperty( "Rotation angle", "The angle to rotate.", 0.0 );
m_angle->setMin( 0.0 );
m_angle->setMax( 2.0 * piDouble );
m_angle->setMax( 2.0 * pi() );
}
WManipulatorRotation::~WManipulatorRotation()
......
......@@ -177,15 +177,15 @@ void WMNavigationSlices::initOSG()
m_coronalOutput->setMatrix(
osg::Matrixd::translate( -midBB[0], -midBB[1], -midBB[2] ) *
osg::Matrixd::scale( maxSizeInv, maxSizeInv, maxSizeInv ) *
osg::Matrixd::rotate( -0.5 * piDouble, 1.0, 0.0 , 0.0 ) *
osg::Matrixd::rotate( -0.5 * pi(), 1.0, 0.0 , 0.0 ) *
osg::Matrixd::translate( 0.0, 0.0, -0.5 )
);
m_sagittalOutput->setMatrix(
osg::Matrixd::translate( -midBB[0], -midBB[1], -midBB[2] ) *
osg::Matrixd::scale( maxSizeInv, maxSizeInv, maxSizeInv ) *
osg::Matrixd::rotate( -0.5 * piDouble, 1.0, 0.0 , 0.0 ) *
osg::Matrixd::rotate( 0.5 * piDouble, 0.0, 1.0 , 0.0 ) *
osg::Matrixd::rotate( -0.5 * pi(), 1.0, 0.0 , 0.0 ) *
osg::Matrixd::rotate( 0.5 * pi(), 0.0, 1.0 , 0.0 ) *
osg::Matrixd::translate( 0.0, 0.0, -0.5 )
);
......
......@@ -496,9 +496,9 @@ void WMTriangleMeshRenderer::updateTransformation()
osg::Matrixd matrixTranslateTo0 = osg::Matrixd::translate( static_cast< osg::Vec3f >( m_meshCenter ) * -1.0 );
osg::Matrixd matrixTranslateFrom0 = osg::Matrixd::translate( static_cast< osg::Vec3f >( m_meshCenter ) );
osg::Matrixd matrixScale = osg::Matrixd::scale( m_scaleX->get(), m_scaleY->get(), m_scaleZ->get() );
osg::Matrixd matrixRotateX = osg::Matrixd::rotate( m_rotateX->get() * piDouble / 180, osg::Vec3f( 1, 0, 0 ) );
osg::Matrixd matrixRotateY = osg::Matrixd::rotate( m_rotateY->get() * piDouble / 180, osg::Vec3f( 0, 1, 0 ) );
osg::Matrixd matrixRotateZ = osg::Matrixd::rotate( m_rotateZ->get() * piDouble / 180, osg::Vec3f( 0, 0, 1 ) );
osg::Matrixd matrixRotateX = osg::Matrixd::rotate( m_rotateX->get() * pi() / 180, osg::Vec3f( 1, 0, 0 ) );
osg::Matrixd matrixRotateY = osg::Matrixd::rotate( m_rotateY->get() * pi() / 180, osg::Vec3f( 0, 1, 0 ) );
osg::Matrixd matrixRotateZ = osg::Matrixd::rotate( m_rotateZ->get() * pi() / 180, osg::Vec3f( 0, 0, 1 ) );
osg::Matrixd matrixRotate = matrixRotateX * matrixRotateY * matrixRotateZ;
osg::Matrixd matrixTranslate = osg::Matrixd::translate( m_translateX->get(), m_translateY->get(), m_translateZ->get() );
osg::Matrixd matrixComplete =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment