Jump to content

[SOLVED] Sun azimuth and elevation


photo

Recommended Posts

Posted

Hello, everyone, 
can you give me any advice on how to get a vector described by azimuth and elevation of the sun.

See the picture. Thank you for any help. 

Michal

sun.thumb.png.b2dd29ae4b02b6ac10ea2af505971de9.png

Posted

Hello! try something like this:

vec3 sun_dir = sun->getWorldDirection(AXIS_Z);
float azimuth = Math::atan2(sun_dir.x, sun_dir.y) * Math::Consts::RAD2DEG
float elevation = Math::acos(clamp(-sun_dir.z, -1.0f, 1.0f)) * Math::Consts::RAD2DEG - 90.0f

 

  • Like 1
  • Thanks 1
Posted

Thank you very much , it is works as I expected 

  • silent changed the title to [SOLVED] Sun azimuth and elevation
×
×
  • Create New...