Skip to content

Commit

Permalink
[opencl] Small optimization in hillshade
Browse files Browse the repository at this point in the history
... and more tolerant epsilon for float comparison in tests
  • Loading branch information
elpaso committed Aug 8, 2018
1 parent 82b60df commit b89808f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
21 changes: 0 additions & 21 deletions resources/opencl_programs/hillshade.cl
@@ -1,11 +1,8 @@
#include "calcfirstder.cl"
<<<<<<< 30a62e1addd2541bdbecda4398381772eb8034d4

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
=======
>>>>>>> [opencl] Fix small OpenCL alg issues

__kernel void processNineCellWindow( __global float *scanLine1,
__global float *scanLine2,
Expand Down Expand Up @@ -42,7 +39,6 @@ __kernel void processNineCellWindow( __global float *scanLine1,
else
{

<<<<<<< 30a62e1addd2541bdbecda4398381772eb8034d4
float slope_rad = sqrt( derX * derX + derY * derY );
slope_rad = atan( slope_rad );
float aspect_rad;
Expand All @@ -54,23 +50,6 @@ __kernel void processNineCellWindow( __global float *scanLine1,
resultLine[i] = max(0.0f, 255.0f * ( ( rasterParams[5] * cos( slope_rad ) ) +
( rasterParams[6] * sin( slope_rad ) *
cos( rasterParams[7] - aspect_rad ) ) ) );
=======
float zenith_rad = rasterParams[5];
float azimuth_rad = rasterParams[6];
float slope_rad = sqrt( derX * derX + derY * derY );


slope_rad = atan( slope_rad );
float aspect_rad;
if ( derX == 0.0f && derY == 0.0f)
aspect_rad = azimuth_rad / 2.0f;
else
aspect_rad = M_PI + atan2( derX, derY );

resultLine[i] = max(0.0f, 255.0f * ( ( cos( zenith_rad ) * cos( slope_rad ) ) +
( sin( zenith_rad ) * sin( slope_rad ) *
cos( azimuth_rad - aspect_rad ) ) ) );
>>>>>>> [opencl] Fix small OpenCL alg issues

}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/analysis/testqgsninecellfilters.cpp
Expand Up @@ -180,7 +180,7 @@ void TestNineCellFilters::_rasterCompare( QgsAlignRaster::RasterInfo &out, QgsA
QCOMPARE( out.cellSize(), refCellSize );

// If the values differ less than tolerance they are considered equal
double tolerance = 0.0000001;
double tolerance = 0.0001;

// Check three points
std::map<int, int> controlPoints;
Expand Down

0 comments on commit b89808f

Please sign in to comment.