/* * This file is part of libgim. * * libgim is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * libgim is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with libgim. If not, see . * * Copyright 2011-14 Danny Robson */ #ifndef __UTIL_POINT_HPP #define __UTIL_POINT_HPP #include "vector.hpp" #include "detail/coord.hpp" #include #include #include namespace util { /// An n-dimensional position in space. template struct point : public detail::coord { static_assert (S > 0, "point dimensions must be strictly positive."); point (); template point (U ...u): detail::coord {std::forward (u)...} { ; } // point operators T distance (const point &) const; T distance2 (const point &) const; T manhattan (const point &) const; vector to (const point&) const; // arithetic operators point& operator*= (T); point operator* (T) const; point operator- (const point&) const; point operator- (const vector&) const; point& operator-= (const vector&); point operator+ (const vector&) const; point& operator+= (const vector&); template point redim (void) const; void sanity (void) const; }; // free maths operators template point operator* (const vector&, const point&); template point operator* (const point&, const vector&); // iostream operators template std::ostream& operator<< (std::ostream&, const point&); // Convenience typedefs typedef point<2,float> point2f; typedef point<3,float> point3f; typedef point<2,double> point2d; typedef point<3,double> point3d; typedef point<2,size_t> point2u; } #include "point.ipp" #endif // __UTIL_POINT_HPP