/////////////////////////////////////////////////////////////////////////////////////////////////// // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2007-03-06 // Updated : 2009-05-01 // Licence : This source is under MIT License // File : glm/gtx/polar_coordinates.inl /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm { template GLM_FUNC_QUALIFIER tvec3 polar ( tvec3 const & euclidean ) { T const Length(length(euclidean)); tvec3 const tmp(euclidean / Length); T const xz_dist(sqrt(tmp.x * tmp.x + tmp.z * tmp.z)); return tvec3( atan(xz_dist, tmp.y), // latitude atan(tmp.x, tmp.z), // longitude xz_dist); // xz distance } template GLM_FUNC_QUALIFIER tvec3 euclidean ( tvec2 const & polar ) { T const latitude(polar.x); T const longitude(polar.y); return tvec3( cos(latitude) * sin(longitude), sin(latitude), cos(latitude) * cos(longitude)); } }//namespace glm