VISR  0.11.1
Versatile Interactive Scene Renderer
cartesian_spherical_conversion.hpp
Go to the documentation of this file.
1 /* Copyright Institute of Sound and Vibration Research - All rights reserved */
2 
10 #ifndef VISR_LIBEFL_CARTESIAN_SPHERICAL_CONVERSION_HPP_INCLUDED
11 #define VISR_LIBEFL_CARTESIAN_SPHERICAL_CONVERSION_HPP_INCLUDED
12 
13 #include <cmath>
14 #include <tuple>
15 
16 
17 namespace visr
18 {
19 namespace efl
20 {
21 
30 template< typename T >
31 std::tuple< T, T, T > spherical2cartesian( T az, T el, T radius )
32 {
33  return std::make_tuple( std::cos( az )*std::cos( el ) * radius,
34  std::sin( az )*std::cos( el ) * radius,
35  std::sin( el ) * radius );
36 }
37 
47 template< typename T >
48 std::tuple< T, T, T > cartesian2spherical( T x, T y, T z )
49 {
50  T const radius = std::sqrt( x*x + y*y + z*z );
51  T const az = std::atan2( y, x );
52  T const el = std::asin( z / radius );
53  return std::make_tuple( az, el, radius );
54 }
55 
56 } // namespace efl
57 } // namespace visr
58 
59 #endif // #ifndef VISR_LIBEFL_CARTESIAN_SPHERICAL_CONVERSION_HPP_INCLUDED
std::tuple< T, T, T > spherical2cartesian(T az, T el, T radius)
Definition: cartesian_spherical_conversion.hpp:31
std::tuple< T, T, T > cartesian2spherical(T x, T y, T z)
Definition: cartesian_spherical_conversion.hpp:48
Definition: options.cpp:10