43 #ifndef FASTRACK_CONTROL_VECTOR_BOUND_BOX_H 44 #define FASTRACK_CONTROL_VECTOR_BOUND_BOX_H 58 throw std::runtime_error(
"Inconsistent bound dimensions.");
64 if (!params.size() || params.size() & 1)
65 throw std::runtime_error(
"Incorrect number of parameters.");
67 const size_t dimension = params.size() >> 1;
69 min_.resize(dimension);
70 for (
size_t ii = 0; ii < dimension; ii++)
min_(ii) = params[ii];
72 max_.resize(dimension);
73 for (
size_t ii = 0; ii < dimension; ii++)
max_(ii) = params[dimension + ii];
77 inline const VectorXd&
Min()
const {
return min_; }
78 inline const VectorXd&
Max()
const {
return max_; }
82 if (&other ==
this)
return *
this;
90 inline bool Contains(
const VectorXd& query)
const {
91 if (
min_.size() != query.size())
92 throw std::runtime_error(
"Incorrect query dimension.");
94 for (
size_t ii = 0; ii <
min_.size(); ii++) {
95 if (
min_(ii) > query(ii) || query(ii) >
max_(ii))
return false;
106 if (
min_.size() != query.size())
107 throw std::runtime_error(
"Incorrect query dimension.");
109 VectorXd projection(
min_.size());
110 for (
size_t ii = 0; ii <
min_.size(); ii++)
111 projection(ii) = (query(ii) >= 0.0) ?
max_(ii) :
min_(ii);
VectorXd ProjectToSurface(const VectorXd &query) const
VectorBoundBox & operator=(const VectorBoundBox &other)
const VectorXd & Min() const
VectorBoundBox(const VectorXd &min, const VectorXd &max)
bool Contains(const VectorXd &query) const
const VectorXd & Max() const
VectorBoundBox(const std::vector< double > ¶ms)