24 , mLightAzimuth( static_cast<float>( lightAzimuth ) )
25 , mLightAngle( static_cast<float>( lightAngle ) )
26 , mCosZenithRad( std::cos( static_cast<float>( lightAngle * M_PI ) / 180.0f ) )
27 , mSinZenithRad( std::sin( static_cast<float>( lightAngle * M_PI ) / 180.0f ) )
28 , mAzimuthRad( static_cast<float>( lightAzimuth * M_PI ) / 180.0f )
33 float *x12,
float *x22,
float *x32,
34 float *x13,
float *x23,
float *x33 )
37 const float derX =
calcFirstDerX( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
38 const float derY =
calcFirstDerY( x11, x21, x31, x12, x22, x32, x13, x23, x33 );
45 const float slope_rad = std::atan( std::sqrt( derX * derX + derY * derY ) );
47 if ( derX == 0 && derY == 0 )
49 aspect_rad = mAzimuthRad / 2.0f;
53 aspect_rad = M_PI + std::atan2( derX, derY );
55 return std::max( 0.0f, 255.0f * ( ( mCosZenithRad * std::cos( slope_rad ) ) +
56 ( mSinZenithRad * std::sin( slope_rad ) *
57 std::cos( mAzimuthRad - aspect_rad ) ) ) );
62 mLightAzimuth = azimuth;
63 mAzimuthRad = azimuth *
static_cast<float>( M_PI ) / 180.0f;
69 mCosZenithRad = std::cos(
angle *
static_cast<float>( M_PI ) / 180.0f );
70 mSinZenithRad = std::sin(
angle *
static_cast<float>( M_PI ) / 180.0f );
75 void QgsHillshadeFilter::addExtraRasterParams( std::vector<float> ¶ms )
78 params.push_back( mCosZenithRad );
79 params.push_back( mSinZenithRad );
80 params.push_back( mAzimuthRad );