1/////////////////////////////////////////////////////////////////////////////////////////////////// 2// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3/////////////////////////////////////////////////////////////////////////////////////////////////// 4// Created : 2007-03-06 5// Updated : 2009-05-01 6// Licence : This source is under MIT License 7// File : glm/gtx/polar_coordinates.inl 8/////////////////////////////////////////////////////////////////////////////////////////////////// 9 10namespace glm 11{ 12 template <typename T, precision P> 13 GLM_FUNC_QUALIFIER detail::tvec3<T, P> polar 14 ( 15 detail::tvec3<T, P> const & euclidean 16 ) 17 { 18 T const Length(length(euclidean)); 19 detail::tvec3<T, P> const tmp(euclidean / Length); 20 T const xz_dist(sqrt(tmp.x * tmp.x + tmp.z * tmp.z)); 21 22#ifdef GLM_FORCE_RADIANS 23 return detail::tvec3<T, P>( 24 atan(xz_dist, tmp.y), // latitude 25 atan(tmp.x, tmp.z), // longitude 26 xz_dist); // xz distance 27#else 28# pragma message("GLM: polar function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.") 29 return detail::tvec3<T, P>( 30 degrees(atan(xz_dist, tmp.y)), // latitude 31 degrees(atan(tmp.x, tmp.z)), // longitude 32 xz_dist); // xz distance 33#endif 34 } 35 36 template <typename T, precision P> 37 GLM_FUNC_QUALIFIER detail::tvec3<T, P> euclidean 38 ( 39 detail::tvec2<T, P> const & polar 40 ) 41 { 42#ifdef GLM_FORCE_RADIANS 43 T const latitude(polar.x); 44 T const longitude(polar.y); 45#else 46# pragma message("GLM: euclidean function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.") 47 T const latitude(radians(polar.x)); 48 T const longitude(radians(polar.y)); 49#endif 50 51 return detail::tvec3<T, P>( 52 cos(latitude) * sin(longitude), 53 sin(latitude), 54 cos(latitude) * cos(longitude)); 55 } 56 57}//namespace glm 58