Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #5074 from nyalldawson/cleanup
Remove some redundant and unused MathUtils methods
  • Loading branch information
nyalldawson committed Aug 26, 2017
2 parents 650cf6a + 43200ea commit 5e94546
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 75 deletions.
70 changes: 1 addition & 69 deletions src/analysis/interpolation/MathUtils.cc
Expand Up @@ -220,22 +220,7 @@ double MathUtils::distPointFromLine( QgsPoint *thepoint, QgsPoint *p1, QgsPoint

int MathUtils::faculty( int n )
{
if ( n < 0 )//Is faculty also defined for negative integers?
{
QgsDebugMsg( "Error, faculty of a negative integer requested!" );
return 0;
}
int i;
int result = n;

if ( n == 0 || n == 1 )
{return 1;}//faculty of 0 is 1!

for ( i = n - 1; i >= 2; i-- )
{
result *= i;
}
return result;
return std::tgamma( n + 1 );
}

bool MathUtils::inCircle( QgsPoint *testp, QgsPoint *p1, QgsPoint *p2, QgsPoint *p3 )
Expand Down Expand Up @@ -431,59 +416,6 @@ int MathUtils::lower( int n, int i )
}
}

double MathUtils::max( double x, double y )
{
if ( x > y )
{
return x;
}
else if ( y > x )
{
return y;
}
else//if both are equal
{
return x;
}
}
double MathUtils::min( double x, double y )
{
if ( x < y )
{
return x;
}
else if ( y < x )
{
return y;
}
else//if both are equal
{
return x;
}
}

double MathUtils::power( double a, int b )
{
if ( b == 0 )
{
return 1;
}
double tmp = a;
for ( int i = 2; i <= std::abs( b ); i++ )
{

a *= tmp;
}
if ( b > 0 )
{
return a;
}
else
{
return ( 1.0 / a );
}
}

double MathUtils::triArea( QgsPoint *pa, QgsPoint *pb, QgsPoint *pc )
{
if ( pa && pb && pc )
Expand Down
6 changes: 0 additions & 6 deletions src/analysis/interpolation/MathUtils.h
Expand Up @@ -54,12 +54,6 @@ namespace MathUtils
bool ANALYSIS_EXPORT lineIntersection( QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4, QgsPoint *intersection_point );
//! Lower function
int ANALYSIS_EXPORT lower( int n, int i );
//! Returns the maximum of two doubles or the first argument if both are equal
double ANALYSIS_EXPORT max( double x, double y );
//! Returns the minimum of two doubles or the first argument if both are equal
double ANALYSIS_EXPORT min( double x, double y );
//! Power function for integer coefficients
double ANALYSIS_EXPORT power( double a, int b );//calculates a power b
//! Returns the area of a triangle. If the points are ordered counterclockwise, the value will be positiv. If they are ordered clockwise, the value will be negativ
double ANALYSIS_EXPORT triArea( QgsPoint *pa, QgsPoint *pb, QgsPoint *pc );
//! Calculates the z-component of a vector with coordinates 'x' and 'y'which is in the same tangent plane as the tangent vectors 'v1' and 'v2'. The result is assigned to 'result'
Expand Down

0 comments on commit 5e94546

Please sign in to comment.