Claw  1.7.0
coordinate_2d.hpp
Go to the documentation of this file.
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 
00023   contact: julien.jorge@gamned.org
00024 */
00030 #ifndef __CLAW_COORDINATE_2D_HPP__
00031 #define __CLAW_COORDINATE_2D_HPP__
00032 
00033 namespace claw
00034 {
00035   namespace math
00036   {
00041     template<typename T>
00042     class coordinate_2d
00043     {
00044     public:
00046       typedef T value_type;
00047 
00049       typedef coordinate_2d<value_type> self_type;
00050 
00051     public:
00052       coordinate_2d();
00053 
00054       template<typename U>
00055       coordinate_2d( const coordinate_2d<U>& that );
00056 
00057       coordinate_2d( const value_type& _x, const value_type& _y );
00058 
00059       template<typename U>
00060       coordinate_2d<U> cast_value_type_to() const;
00061 
00062       void set(const value_type& _x, const value_type& _y);
00063       value_type distance(const self_type& p) const;
00064 
00065       void rotate( const self_type& center, double angle );
00066       double slope_angle( const self_type& to ) const;
00067 
00068       bool operator==(const self_type& vect) const;
00069       bool operator!=(const self_type& vect) const;
00070       self_type operator+(const self_type& vect) const;
00071       self_type operator-(const self_type& vect) const;
00072       self_type& operator+=(const self_type& vect);
00073       self_type& operator-=(const self_type& vect);
00074 
00075       self_type operator*( const value_type& v ) const;
00076       self_type operator/( const value_type& v ) const;
00077       self_type& operator*=( const value_type& v );
00078       self_type& operator/=( const value_type& v );
00079 
00080     public:
00082       value_type x;
00083 
00085       value_type y;
00086 
00087     }; // class coordinate_2d
00088 
00089     template<typename T>
00090     coordinate_2d<T> operator-( const coordinate_2d<T>& that );
00091 
00092     template<typename T, typename U>
00093     coordinate_2d<T> operator*( U v, const coordinate_2d<T>& self );
00094 
00095   } // namespace math
00096 } // namespace claw
00097 
00098 #include <claw/impl/coordinate_2d.tpp>
00099 
00100 #endif // __CLAW_COORDINATE_2D_HPP__