WFMath
1.0.1
|
00001 // line_funcs.h (Line<> implementation) 00002 // 00003 // The WorldForge Project 00004 // Copyright (C) 2012 The WorldForge Project 00005 // 00006 // This program is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with this program; if not, write to the Free Software 00018 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 // 00020 // For information about WorldForge and its authors, please contact 00021 // the Worldforge Web Site at http://www.worldforge.org. 00022 // 00023 00024 // Author: Al Riddoch 00025 00026 #ifndef WFMATH_LINE_FUNCS_H 00027 #define WFMATH_LINE_FUNCS_H 00028 00029 #include <wfmath/line.h> 00030 00031 namespace WFMath { 00032 00033 template<int dim> 00034 inline bool Line<dim>::isEqualTo(const Line<dim> & l, CoordType epsilon) const 00035 { 00036 size_type size = m_points.size(); 00037 if (size != l.m_points.size()) { 00038 return false; 00039 } 00040 00041 for (size_type i = 0; i < size; ++i) { 00042 if (!Equal(m_points[i], l.m_points[i], epsilon)) { 00043 return false; 00044 } 00045 } 00046 00047 return true; 00048 } 00049 00050 template<int dim> 00051 inline Line<dim>& Line<dim>::shift(const Vector<dim>& v) 00052 { 00053 for (iterator i = m_points.begin(); i != m_points.end(); ++i) { 00054 *i += v; 00055 } 00056 00057 return *this; 00058 } 00059 00060 template<int dim> 00061 inline Line<dim>& Line<dim>::rotatePoint(const RotMatrix<dim>& m, 00062 const Point<dim>& p) 00063 { 00064 for (iterator i = m_points.begin(); i != m_points.end(); ++i) { 00065 i->rotate(m, p); 00066 } 00067 00068 return *this; 00069 } 00070 00071 } // namespace WFMath 00072 00073 #endif // WFMATH_LINE_FUNCS_H