politopix  4.1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Point_Rn.h
Go to the documentation of this file.
1 // politopix allows to make computations on polytopes such as finding vertices, intersecting, Minkowski sums, ...
2 // Copyright (C) 2011-2015 : Delos Vincent
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
19 // I2M (UMR CNRS 5295 / University of Bordeaux)
20 
21 #ifndef POINT_Rn
22 #define POINT_Rn
23 
24 #include <algorithm>
25 #include <stdexcept>
26 #include <exception>
27 #include <boost/numeric/ublas/vector.hpp>
28 #include <boost/numeric/ublas/io.hpp>
29 #include "polito_Export.h"
30 
31 using namespace boost::numeric::ublas;
32 
35 
36  public:
37  // Think about in the future to an empty constructor
38  // reading the dimension stored in a static variable.
40  Point_Rn(unsigned int n);
41 
43  Point_Rn(unsigned int n, double u);
44 
46  Point_Rn(double u1, double u2, double u3);
47 
48  virtual ~Point_Rn();
49 
50  double normalize();
51 
52  double distanceFrom(const Point_Rn&);
53 
54  void setCoordinate(unsigned int i, double val) throw (std::out_of_range);
55 
56  double getCoordinate(unsigned int i) const throw (std::out_of_range);
57 
58  int dimension() const {return _coordinates.size();}
59 
60  void load(std::istream &this_istream);
61 
62  void save(std::ostream &this_ostream) const;
63 
64  vector<double>::const_iterator begin() const {return _coordinates.begin();}
65 
66  vector<double>::const_iterator end() const {return _coordinates.end();}
67 
68  const vector<double>& vect() const {return _coordinates;}
69 
70  void negate() { _coordinates = -1.*_coordinates; }
71 
73  static std::string concatStrings(int i, const std::string& functionName);
74 
76  static std::string concatStrings(int i, double val, const std::string& functionName);
77 
78  protected:
79  // Create an empty set of coordinates.
80  vector<double> _coordinates;
81 
82 };
83 
84 
85 #endif // POINT_Rn
int dimension() const
Definition: Point_Rn.h:58
Creation of a n-coordinate geometric point designed to be shared by its neighbour faces...
Definition: Point_Rn.h:34
vector< double > _coordinates
Definition: Point_Rn.h:80
vector< double >::const_iterator begin() const
Definition: Point_Rn.h:64
#define polito_EXPORT
Definition: polito_Export.h:15
void negate()
Definition: Point_Rn.h:70
const vector< double > & vect() const
Definition: Point_Rn.h:68
vector< double >::const_iterator end() const
Definition: Point_Rn.h:66