Skip to content
Snippets Groups Projects
Commit 2636b2e7 authored by Thomas Feuvrier's avatar Thomas Feuvrier
Browse files

Remplacement des vcl_acos(-1) par M_PI

parent d4ded221
Branches
Tags
No related merge requests found
Showing
with 29 additions and 19 deletions
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "otbInverseLogPolarTransform.h" #include "otbInverseLogPolarTransform.h"
#include "otbMacro.h" #include "otbMacro.h"
#include "otbMath.h"
namespace otb namespace otb
{ {
...@@ -96,7 +97,7 @@ typename InverseLogPolarTransform<TScalarType> ...@@ -96,7 +97,7 @@ typename InverseLogPolarTransform<TScalarType>
{ {
result[0]=(1/m_Scale[0])*vcl_asin((point[1]-m_Center[1])/rho); result[0]=(1/m_Scale[0])*vcl_asin((point[1]-m_Center[1])/rho);
// degree conversion // degree conversion
result[0]=result[0]*(180/vcl_acos(-1.0)); result[0]=result[0]*(180/M_PI);
// Deplacing the range to [0,90], [270,360] // Deplacing the range to [0,90], [270,360]
result[0]= result[0]>0 ? result[0] : result[0]+360; result[0]= result[0]>0 ? result[0] : result[0]+360;
// Avoiding asin indetermination // Avoiding asin indetermination
...@@ -132,7 +133,7 @@ InverseLogPolarTransform<TScalarType> ...@@ -132,7 +133,7 @@ InverseLogPolarTransform<TScalarType>
{ {
result[0]=(1/m_Scale[0])*vcl_asin((vector[1]-m_Center[1])/rho); result[0]=(1/m_Scale[0])*vcl_asin((vector[1]-m_Center[1])/rho);
// degree conversion // degree conversion
result[0]=result[0]*(180/vcl_acos(-1.0)); result[0]=result[0]*(180/M_PI);
// Deplacing the range to [0,90], [270,360] // Deplacing the range to [0,90], [270,360]
result[0]= result[0]>0 ? result[0] : result[0]+360; result[0]= result[0]>0 ? result[0] : result[0]+360;
// Avoiding asin indetermination // Avoiding asin indetermination
...@@ -168,7 +169,7 @@ InverseLogPolarTransform<TScalarType> ...@@ -168,7 +169,7 @@ InverseLogPolarTransform<TScalarType>
{ {
result[0]=(1/m_Scale[0])*vcl_asin((vector[1]-m_Center[1])/rho); result[0]=(1/m_Scale[0])*vcl_asin((vector[1]-m_Center[1])/rho);
// degree conversion // degree conversion
result[0]=result[0]*(180/vcl_acos(-1.0)); result[0]=result[0]*(180/M_PI);
// Deplacing the range to [0,90], [270,360] // Deplacing the range to [0,90], [270,360]
result[0]= result[0]>0 ? result[0] : result[0]+360; result[0]= result[0]>0 ? result[0] : result[0]+360;
// Avoiding vcl_asin indetermination // Avoiding vcl_asin indetermination
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "otbLogPolarTransform.h" #include "otbLogPolarTransform.h"
#include "otbMacro.h" #include "otbMacro.h"
#include "otbMath.h"
namespace otb namespace otb
{ {
...@@ -90,7 +91,7 @@ typename LogPolarTransform<TScalarType> ...@@ -90,7 +91,7 @@ typename LogPolarTransform<TScalarType>
::TransformPoint(const InputPointType &point) const ::TransformPoint(const InputPointType &point) const
{ {
OutputPointType result; OutputPointType result;
double theta = point[0]*m_Scale[0]*vcl_acos(-1.0)/180.0; double theta = point[0]*m_Scale[0]*M_PI/180.0;
double logRho = point[1]*m_Scale[1]; double logRho = point[1]*m_Scale[1];
result[0]=m_Center[0]; result[0]=m_Center[0];
result[1]=m_Center[1]; result[1]=m_Center[1];
...@@ -110,7 +111,7 @@ LogPolarTransform<TScalarType> ...@@ -110,7 +111,7 @@ LogPolarTransform<TScalarType>
::TransformVector(const InputVectorType &vector) const ::TransformVector(const InputVectorType &vector) const
{ {
OutputVectorType result; OutputVectorType result;
double theta = vector[0]*m_Scale[0]*vcl_acos(-1.0)/180.0; double theta = vector[0]*m_Scale[0]*M_PI/180.0;
double logRho = vector[1]*m_Scale[1]; double logRho = vector[1]*m_Scale[1];
result[0]=0.; result[0]=0.;
result[1]=0.; result[1]=0.;
...@@ -131,7 +132,7 @@ LogPolarTransform<TScalarType> ...@@ -131,7 +132,7 @@ LogPolarTransform<TScalarType>
::TransformVector(const InputVnlVectorType &vector) const ::TransformVector(const InputVnlVectorType &vector) const
{ {
OutputVnlVectorType result; OutputVnlVectorType result;
double theta = vector[0]*m_Scale[0]*vcl_acos(-1.0)/180.0; double theta = vector[0]*m_Scale[0]*M_PI/180.0;
double logRho = vector[1]*m_Scale[1]; double logRho = vector[1]*m_Scale[1];
result[0]=0.; result[0]=0.;
result[1]=0.; result[1]=0.;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "otbInverseLogPolarTransform.h" #include "otbInverseLogPolarTransform.h"
#include "otbMacro.h" #include "otbMacro.h"
#include <fstream> #include <fstream>
#include "otbMath.h"
int otbInverseLogPolarTransform(int argc, char* argv[]) int otbInverseLogPolarTransform(int argc, char* argv[])
{ {
...@@ -66,7 +67,7 @@ try ...@@ -66,7 +67,7 @@ try
if(rho>0) if(rho>0)
{ {
pprime[0]=(1/angularStep)*vcl_asin((*it)[1]/rho); pprime[0]=(1/angularStep)*vcl_asin((*it)[1]/rho);
pprime[0]=pprime[0]*(180/vcl_acos(-1.0)); pprime[0]=pprime[0]*(180/M_PI);
// Deplacing the range to [0,90], [270,360] // Deplacing the range to [0,90], [270,360]
pprime[0]= pprime[0]>0 ? pprime[0] : pprime[0]+360; pprime[0]= pprime[0]>0 ? pprime[0] : pprime[0]+360;
// Avoiding asin indetermination // Avoiding asin indetermination
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "otbLogPolarTransform.h" #include "otbLogPolarTransform.h"
#include "itkPoint.h" #include "itkPoint.h"
#include "otbMacro.h" #include "otbMacro.h"
#include "otbMath.h"
#include <fstream> #include <fstream>
int otbLogPolarTransform(int argc, char* argv[]) int otbLogPolarTransform(int argc, char* argv[])
...@@ -65,7 +66,7 @@ try ...@@ -65,7 +66,7 @@ try
PointType pprime; PointType pprime;
double theta = (*it)[0]*angularStep*vcl_acos(-1.0)/180.0; double theta = (*it)[0]*angularStep*M_PI/180.0;
double logRho = (*it)[1]*radialStep; double logRho = (*it)[1]*radialStep;
file <<"Rho: "<<logRho<<", Theta: "<<theta<<std::endl; file <<"Rho: "<<logRho<<", Theta: "<<theta<<std::endl;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "itkPolyLineParametricPath.h" #include "itkPolyLineParametricPath.h"
#include "otbOrientationPathFunction.h" #include "otbOrientationPathFunction.h"
#include "otbPathListToHistogramGenerator.h" #include "otbPathListToHistogramGenerator.h"
#include "otbMath.h"
int otbPathListToHistogramGenerator( int argc, char* argv[] ) int otbPathListToHistogramGenerator( int argc, char* argv[] )
{ {
...@@ -55,7 +56,7 @@ int otbPathListToHistogramGenerator( int argc, char* argv[] ) ...@@ -55,7 +56,7 @@ int otbPathListToHistogramGenerator( int argc, char* argv[] )
cindex[1]=30; cindex[1]=30;
pathElt->AddVertex(cindex); pathElt->AddVertex(cindex);
float Theta = 2.0*static_cast<float>(vcl_acos(-1.))*static_cast<float>(i)/static_cast<float>(NbAngle); float Theta = 2.0*static_cast<float>(M_PI)*static_cast<float>(i)/static_cast<float>(NbAngle);
cindex[0]= 30 + vcl_cos(Theta); cindex[0]= 30 + vcl_cos(Theta);
cindex[1]= 30 + vcl_sin(Theta); cindex[1]= 30 + vcl_sin(Theta);
pathElt->AddVertex(cindex); pathElt->AddVertex(cindex);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "itkPolyLineParametricPath.h" #include "itkPolyLineParametricPath.h"
#include <fstream> #include <fstream>
#include <vector> #include <vector>
#include "otbMath.h"
int otbBreakAngularPathListFilter(int argc, char * argv[]) int otbBreakAngularPathListFilter(int argc, char * argv[])
{ {
...@@ -104,7 +105,7 @@ int otbBreakAngularPathListFilter(int argc, char * argv[]) ...@@ -104,7 +105,7 @@ int otbBreakAngularPathListFilter(int argc, char * argv[])
{ {
breakAngularFilter->SetMaxAngle((*itAngle)*vcl_acos(-1.0)/180.); breakAngularFilter->SetMaxAngle((*itAngle)*M_PI/180.);
breakAngularFilter->Update(); breakAngularFilter->Update();
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "otbCompacityPathFunction.h" #include "otbCompacityPathFunction.h"
#include "itkPolyLineParametricPath.h" #include "itkPolyLineParametricPath.h"
#include "itkExceptionObject.h" #include "itkExceptionObject.h"
#include "otbMath.h"
int otbCompacityPathCircle( int argc, char * argv[] ) int otbCompacityPathCircle( int argc, char * argv[] )
{ {
...@@ -47,7 +48,7 @@ int otbCompacityPathCircle( int argc, char * argv[] ) ...@@ -47,7 +48,7 @@ int otbCompacityPathCircle( int argc, char * argv[] )
RealType deltaTheta; RealType deltaTheta;
RealType Rho = 100.0; RealType Rho = 100.0;
deltaTheta = 2.* vcl_acos(-1.0) / static_cast<RealType>(NbOfPoints); deltaTheta = 2.* M_PI / static_cast<RealType>(NbOfPoints);
pathElt->Initialize(); pathElt->Initialize();
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "otbCompacityPathFunction.h" #include "otbCompacityPathFunction.h"
#include "itkPolyLineParametricPath.h" #include "itkPolyLineParametricPath.h"
#include "itkExceptionObject.h" #include "itkExceptionObject.h"
#include "otbMath.h"
int otbCompacityPathRectangle( int argc, char * argv[] ) int otbCompacityPathRectangle( int argc, char * argv[] )
{ {
...@@ -74,7 +75,7 @@ int otbCompacityPathRectangle( int argc, char * argv[] ) ...@@ -74,7 +75,7 @@ int otbCompacityPathRectangle( int argc, char * argv[] )
std::cout << "Compacity result: " << Result <<std::endl; std::cout << "Compacity result: " << Result <<std::endl;
RealType Error; RealType Error;
Error = vcl_abs(Result - static_cast<RealType>(vcl_acos(-1.0) * A*B / (A+B) / (A+B)) ); Error = vcl_abs(Result - static_cast<RealType>(M_PI * A*B / (A+B) / (A+B)) );
if( Error > 1.E-9) if( Error > 1.E-9)
{ {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "otbCompacityPathFunction.h" #include "otbCompacityPathFunction.h"
#include "itkPolyLineParametricPath.h" #include "itkPolyLineParametricPath.h"
#include "itkExceptionObject.h" #include "itkExceptionObject.h"
#include "otbMath.h"
int otbCompacityPathSquare( int argc, char * argv[] ) int otbCompacityPathSquare( int argc, char * argv[] )
{ {
...@@ -68,7 +69,7 @@ int otbCompacityPathSquare( int argc, char * argv[] ) ...@@ -68,7 +69,7 @@ int otbCompacityPathSquare( int argc, char * argv[] )
std::cout << "Compacity result: " << Result <<std::endl; std::cout << "Compacity result: " << Result <<std::endl;
RealType Error; RealType Error;
Error = vcl_abs(Result - static_cast<RealType>(vcl_acos(-1.0)/4.) ); Error = vcl_abs(Result - static_cast<RealType>(M_PI_4) );
if( Error > 1.E-9) if( Error > 1.E-9)
{ {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "otbLinkPathListFilter.h" #include "otbLinkPathListFilter.h"
#include "itkPolyLineParametricPath.h" #include "itkPolyLineParametricPath.h"
#include <fstream> #include <fstream>
#include "otbMath.h"
int otbLinkPathListFilter(int argc, char * argv[]) int otbLinkPathListFilter(int argc, char * argv[])
{ {
...@@ -30,7 +31,7 @@ int otbLinkPathListFilter(int argc, char * argv[]) ...@@ -30,7 +31,7 @@ int otbLinkPathListFilter(int argc, char * argv[])
{ {
const char * outfname = argv[1]; const char * outfname = argv[1];
const double distance = atof(argv[2]); const double distance = atof(argv[2]);
const double angle = atof(argv[3])*vcl_acos(-1.0)/180.; const double angle = ::atof(argv[3])*M_PI/180.;
typedef std::vector<double> PointsVectorType; typedef std::vector<double> PointsVectorType;
typedef std::vector< PointsVectorType > PointsMatrixType; typedef std::vector< PointsVectorType > PointsMatrixType;
...@@ -106,7 +107,7 @@ int otbLinkPathListFilter(int argc, char * argv[]) ...@@ -106,7 +107,7 @@ int otbLinkPathListFilter(int argc, char * argv[])
PathListIteratorType pathListIt = InputPathList->Begin(); PathListIteratorType pathListIt = InputPathList->Begin();
file<<"Maximum distance threshold: "<<filter->GetDistanceThreshold()<< " ("<<distance<<")"<<std::endl; file<<"Maximum distance threshold: "<<filter->GetDistanceThreshold()<< " ("<<distance<<")"<<std::endl;
file<<"Maximum angle threshold: "<<filter->GetAngularThreshold()<< " ("<<angle*180/vcl_acos(-1)<<")"<<std::endl; file<<"Maximum angle threshold: "<<filter->GetAngularThreshold()<< " ("<<angle*180/M_PI<<")"<<std::endl;
file<<"INPUT list of Path "<<": "<<std::endl; file<<"INPUT list of Path "<<": "<<std::endl;
while(pathListIt!=InputPathList->End()) while(pathListIt!=InputPathList->End())
{ {
......
...@@ -20,8 +20,7 @@ ...@@ -20,8 +20,7 @@
#pragma warning ( disable : 4786 ) #pragma warning ( disable : 4786 )
#endif #endif
#include <math.h> #include "otbMath.h"
#include "otbOrientationPathFunction.h" #include "otbOrientationPathFunction.h"
#include "itkPolyLineParametricPath.h" #include "itkPolyLineParametricPath.h"
#include "itkExceptionObject.h" #include "itkExceptionObject.h"
...@@ -40,7 +39,7 @@ int otbOrientationPath( int argc, char * argv[] ) ...@@ -40,7 +39,7 @@ int otbOrientationPath( int argc, char * argv[] )
PathType::ContinuousIndexType cindex; PathType::ContinuousIndexType cindex;
PathType::Pointer pathElt = PathType::New(); PathType::Pointer pathElt = PathType::New();
Theta *= vcl_acos(-1.0)/180.; Theta *= M_PI/180.;
pathElt->Initialize(); pathElt->Initialize();
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "otbImageFileReader.h" #include "otbImageFileReader.h"
#include "otbImageFileWriter.h" #include "otbImageFileWriter.h"
#include "otbPolyLineParametricPathWithValue.h" #include "otbPolyLineParametricPathWithValue.h"
#include "otbMath.h"
int otbRoadExtractionFilter(int argc, char * argv[]) int otbRoadExtractionFilter(int argc, char * argv[])
{ {
...@@ -60,7 +61,7 @@ int otbRoadExtractionFilter(int argc, char * argv[]) ...@@ -60,7 +61,7 @@ int otbRoadExtractionFilter(int argc, char * argv[])
const double Alpha = ::atof(argv[7]); const double Alpha = ::atof(argv[7]);
const double AmplitudeThreshold = ::atof(argv[8]); const double AmplitudeThreshold = ::atof(argv[8]);
const double Tolerance = ::atof(argv[9]); const double Tolerance = ::atof(argv[9]);
const double MaxAngle = ((vcl_acos(-1.)*::atof(argv[10]))/180.); const double MaxAngle = ((M_PI*::atof(argv[10]))/180.);
const double FirstMeanDistanceThreshold = ::atof(argv[11]); const double FirstMeanDistanceThreshold = ::atof(argv[11]);
const double SecondMeanDistanceThreshold = ::atof(argv[12]); const double SecondMeanDistanceThreshold = ::atof(argv[12]);
const double LinkAngularThreshold = ::atof(argv[13]); const double LinkAngularThreshold = ::atof(argv[13]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment