politopix  4.1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HalfSpace_Rn.cpp
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 #include <iostream>
22 #include <sstream>
23 #include <string>
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include "Point_Rn.h"
27 #include "HalfSpace_Rn.h"
28 
29 HalfSpace_Rn::HalfSpace_Rn(unsigned int n):_coefficients(n),_constant(0.) {
30 }
31 
33 }
34 
35 double HalfSpace_Rn::getCoefficient(unsigned int i) const throw (std::out_of_range) {
36  if (i < _coefficients.size()) {
37  return _coefficients[i];
38  }
39  else {
40  std::string newErrorMessage = Point_Rn::concatStrings(i, "HalfSpace_Rn::getCoefficient");
41  newErrorMessage += "\n";
42  throw std::out_of_range(newErrorMessage);
43  }
44 }
45 
46 void HalfSpace_Rn::setCoefficient(unsigned int i, double c) throw (std::out_of_range) {
47  if (i < _coefficients.size()) {
48  _coefficients[i] = c;
49  }
50  else {
51  std::string newErrorMessage = Point_Rn::concatStrings(i, "HalfSpace_Rn::setCoefficient");
52  newErrorMessage += "\n";
53  throw std::out_of_range(newErrorMessage);
54  }
55 }
56 
58  if (state == HalfSpace_Rn::hs_ON)
59  return std::string("ON");
60  if (state == HalfSpace_Rn::hs_OUT)
61  return std::string("OUT");
62  if (state == HalfSpace_Rn::hs_IN)
63  return std::string("IN");
64  if (state == HalfSpace_Rn::hs_IN_OR_OUT)
65  return std::string("IN_OR_OUT");
66  return std::string("UNKNOWN");
67 }
double getCoefficient(unsigned int i) const
void setCoefficient(unsigned int i, double c)
static std::string concatStrings(int i, const std::string &functionName)
Useful function to provide error message to the exception mechanism.
Definition: Point_Rn.cpp:79
static std::string getStateAsText(const HalfSpace_Rn::State &)
HalfSpace_Rn(unsigned int n)
Constructor.