Claw
1.7.3
|
00001 /* 00002 CLAW - a C++ Library Absolutely Wonderful 00003 00004 CLAW is a free library without any particular aim but being useful to 00005 anyone. 00006 00007 Copyright (C) 2005-2011 Julien Jorge 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 contact: julien.jorge@gamned.org 00023 */ 00030 #ifndef __CLAW_MATH_COORDINATE_TRAITS_HPP__ 00031 #define __CLAW_MATH_COORDINATE_TRAITS_HPP__ 00032 00033 #include <claw/coordinate_2d.hpp> 00034 #include <claw/vector_2d.hpp> 00035 00036 namespace claw 00037 { 00038 namespace math 00039 { 00046 template< typename C > 00047 struct coordinate_traits; 00048 00054 template<typename T> 00055 struct coordinate_traits< claw::math::coordinate_2d<T> > 00056 { 00058 typedef claw::math::coordinate_2d<T> coordinate_type; 00059 00061 typedef typename coordinate_type::value_type value_type; 00062 00067 static value_type get_x( const coordinate_type& c ) 00068 { 00069 return c.x; 00070 } // get_x() 00071 00076 static value_type get_y( const coordinate_type& c ) 00077 { 00078 return c.y; 00079 } // get_y() 00080 00087 static coordinate_type make_coordinate( value_type x, value_type y ) 00088 { 00089 return coordinate_type(x, y); 00090 } // make_coordinate() 00091 00092 }; // struct coordinate_traits [claw::math::coordinate_2d] 00093 00099 template<typename T> 00100 struct coordinate_traits< claw::math::vector_2d<T> > 00101 { 00103 typedef claw::math::vector_2d<T> coordinate_type; 00104 00106 typedef typename coordinate_type::value_type value_type; 00107 00112 static value_type get_x( const coordinate_type& c ) 00113 { 00114 return c.x; 00115 } // get_x() 00116 00121 static value_type get_y( const coordinate_type& c ) 00122 { 00123 return c.y; 00124 } // get_y() 00125 00132 static coordinate_type make_coordinate( value_type x, value_type y ) 00133 { 00134 return coordinate_type(x, y); 00135 } // make_coordinate() 00136 00137 }; // struct coordinate_traits [claw::math::vector_2d] 00138 00139 } // namespace math 00140 } // namespace claw 00141 00142 #endif // __CLAW_MATH_COORDINATE_TRAITS_HPP__