23 , mLightAzimuth( static_cast<float>( lightAzimuth ) )
24 , mLightAngle( static_cast<float>( lightAngle ) )
25 , mCosZenithRad( std::cos( static_cast<float>( lightAngle * M_PI ) / 180.0f ) )
26 , mSinZenithRad( std::sin( static_cast<float>( lightAngle * M_PI ) / 180.0f ) )
27 , mAzimuthRad( static_cast<float>( lightAzimuth * M_PI ) / 180.0f )
33 const float derX =
calcFirstDerX( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
34 const float derY =
calcFirstDerY( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
41 const float slope_rad = std::atan( std::sqrt( derX * derX + derY * derY ) );
43 if ( derX == 0 && derY == 0 )
45 aspect_rad = mAzimuthRad / 2.0f;
49 aspect_rad = M_PI + std::atan2( derX, derY );
51 return std::max( 0.0f, 255.0f * ( ( mCosZenithRad * std::cos( slope_rad ) ) + ( mSinZenithRad * std::sin( slope_rad ) * std::cos( mAzimuthRad - aspect_rad ) ) ) );
56 mLightAzimuth = azimuth;
57 mAzimuthRad = azimuth *
static_cast<float>( M_PI ) / 180.0f;
63 mCosZenithRad = std::cos( angle *
static_cast<float>( M_PI ) / 180.0f );
64 mSinZenithRad = std::sin( angle *
static_cast<float>( M_PI ) / 180.0f );
69void QgsHillshadeFilter::addExtraRasterParams( std::vector<float> ¶ms )
71 params.push_back( mCosZenithRad );
72 params.push_back( mSinZenithRad );
73 params.push_back( mAzimuthRad );
Adds the ability to calculate derivatives in x- and y-directions.
float calcFirstDerX(float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33) const
Calculates the first order derivative in x-direction according to Horn (1981)
float calcFirstDerY(float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33) const
Calculates the first order derivative in y-direction according to Horn (1981)
float processNineCellWindow(float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33) override
Calculates output value from nine input values.
void setLightAngle(float angle)
QgsHillshadeFilter(const QString &inputFile, const QString &outputFile, const QString &outputFormat, double lightAzimuth=300, double lightAngle=40)
void setLightAzimuth(float azimuth)
float mOutputNodataValue
The nodata value of the output layer.