wfmath 1.0.3
A math library for the Worldforge system.
line_funcs.h
1// line_funcs.h (Line<> implementation)
2//
3// The WorldForge Project
4// Copyright (C) 2012 The WorldForge Project
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19//
20// For information about WorldForge and its authors, please contact
21// the Worldforge Web Site at http://www.worldforge.org.
22//
23
24// Author: Al Riddoch
25
26#ifndef WFMATH_LINE_FUNCS_H
27#define WFMATH_LINE_FUNCS_H
28
29#include <wfmath/line.h>
30
31namespace WFMath {
32
33template<int dim>
34inline bool Line<dim>::isEqualTo(const Line<dim> & l, CoordType epsilon) const
35{
36 size_type size = m_points.size();
37 if (size != l.m_points.size()) {
38 return false;
39 }
40
41 for (size_type i = 0; i < size; ++i) {
42 if (!Equal(m_points[i], l.m_points[i], epsilon)) {
43 return false;
44 }
45 }
46
47 return true;
48}
49
50template<int dim>
52{
53 for (iterator i = m_points.begin(); i != m_points.end(); ++i) {
54 *i += v;
55 }
56
57 return *this;
58}
59
60template<int dim>
62 const Point<dim>& p)
63{
64 for (iterator i = m_points.begin(); i != m_points.end(); ++i) {
65 i->rotate(m, p);
66 }
67
68 return *this;
69}
70
71} // namespace WFMath
72
73#endif // WFMATH_LINE_FUNCS_H
A dim dimensional line.
Definition: line.h:43
bool isEqualTo(const Line &s, CoordType epsilon=numeric_constants< CoordType >::epsilon()) const
generic: check if two classes are equal, up to a given tolerance
Definition: line_funcs.h:34
Line & shift(const Vector< dim > &v)
shape: move the shape by an amount given by the Vector v
Definition: line_funcs.h:51
Line & rotatePoint(const RotMatrix< dim > &m, const Point< dim > &p)
shape: rotate the shape while holding the Point p fixed.
Definition: line_funcs.h:61
A dim dimensional rotation matrix. Technically, a member of the group O(dim).
Definition: rotmatrix.h:87
Generic library namespace.
Definition: shape.h:41
double CoordType
Basic floating point type.
Definition: const.h:140