c++ - Calculation of euler angles -


i need understanding math behind code. x component of returned vec2 , y component of returned vec2. can explain me represent. know function determinate position of vector in sphere coordinates.

glm::vec2 calceulerangles(const glm::vec3& vec) {   glm::vec3 v = glm::normalize(vec);   glm::vec2 result(acos(v.z), atan2(v.y, v.x));   while (result.y < 0.0)     result.y += twopi;    return glm::vec2(glm::degrees(result.x), glm::degrees(result.y)); } 

it calculating spherical coordinates phi , theta unit vector.

the first component (phi) angle between vector , z-axis. second component (theta) angle on xy-plane. assumes vector can expressed follows:

x = cos theta sin phi y = sin theta sin phi z =           cos phi 

if solve this, calculations in function. adding 2 pi y ensures angle between 0 , 2 pi.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -