MINT2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HyperCuboid Class Reference

#include <HyperCuboid.h>

Public Member Functions

const int & getDimension () const
 
 HyperCuboid (int dimension)
 
 HyperCuboid (const HyperPoint &lowCorner, const HyperPoint &highCorner)
 
 HyperCuboid (int dimension, double low, double high)
 
void print (std::ostream &os=std::cout, int endline=1) const
 
HyperPoint getCenter () const
 
bool inVolume (const HyperPoint &coords) const
 
const HyperCuboidinflateCuboid (double percent)
 
double volume () const
 
double getPositiveIntersectionParameter (const HyperLine &line) const
 
HyperPoint getPositiveIntersectionPoint (const HyperLine &line) const
 
double getNegativeIntersectionParameter (const HyperLine &line) const
 
HyperPoint getNegativeIntersectionPoint (const HyperLine &line) const
 
HyperPoint getRandomPoint (TRandom *random=gRandom) const
 
HyperPointSet getRandomPoints (int nPoints=100, TRandom *random=gRandom) const
 
std::vector< HyperPlanegetConnectedHyperPlanes (const HyperPoint &point) const
 
std::vector< HyperPlanegetConnectedHyperPlanes (const HyperPointSet &point) const
 
std::vector< HyperPlanegetBoundaryHyperPlanes () const
 
HyperPoint getOppositePoint (const HyperPoint &point) const
 
HyperPointSet getConnectedVerticies (const HyperPointSet &pointSet) const
 
HyperPointSet getConnectedVerticies (const HyperPoint &point) const
 
HyperPointSet getVertices () const
 
HyperPointSet getEdgeCenters () const
 
HyperCuboid project (std::vector< int > dims) const
 
HyperCuboid projectOpposite (std::vector< int > dims) const
 
bool inVolume (const HyperPoint &coords, std::vector< int > dims) const
 
const HyperPointgetLowCorner () const
 
const HyperPointgetHighCorner () const
 
HyperPointgetLowCorner ()
 
HyperPointgetHighCorner ()
 
HyperCuboid splitAbove (int dimension, double fractionalSplitPoint) const
 
HyperCuboid splitBelow (int dimension, double fractionalSplitPoint) const
 
HyperVolume split (int dimension, double fractionalSplitPoint) const
 
void split (int dimension, double fractionalSplitPoint, HyperVolume &set) const
 
HyperPoint getWidth () const
 
double getWidth (int dim) const
 
bool setCorners (const HyperPoint &lowCorner, const HyperPoint &highCorner)
 
bool operator== (const HyperCuboid &other) const
 
bool operator != (const HyperCuboid &other) const
 
 ~HyperCuboid ()
 

Private Member Functions

void updateFaceCash () const
 

Private Attributes

int _dimension
 
HyperPoint _lowCorner
 
HyperPoint _highCorner
 
std::vector< HyperPlane_faces
 

Detailed Description

Definition at line 28 of file HyperCuboid.h.

Constructor & Destructor Documentation

◆ HyperCuboid() [1/3]

HyperCuboid::HyperCuboid ( int  dimension)

Most basic constructor where only the dimension of the cuboid is specified.

Definition at line 6 of file HyperCuboid.cpp.

6  :
7  _dimension ( dimension ),
8  _lowCorner ( dimension ),
9  _highCorner( dimension )
10 {
11 }
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
int _dimension
Definition: HyperCuboid.h:32
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ HyperCuboid() [2/3]

HyperCuboid::HyperCuboid ( const HyperPoint lowCorner,
const HyperPoint highCorner 
)

Construct the HyperCuboid with two HyperPoints, one in the low corner, and one in the high corner

Definition at line 15 of file HyperCuboid.cpp.

15  :
16  _dimension( lowCorner.size() ),
17  _lowCorner ( _dimension ), //note this assignment sets the dimension of this variable forever, so if
18  _highCorner( _dimension ) //low and high corners are a different size, an error will be thrown inside HyperPoint
19 {
20 
21  if (lowCorner.allLT(highCorner)){
22  _lowCorner = lowCorner;
23  _highCorner = highCorner;
24  }
25  else{
26  ERROR_LOG << "Your lowCorner isn't lower than your highCorner"<< std::endl;
27  _lowCorner .print();
29  }
30 
31 }
int size() const
Definition: HyperPoint.h:96
virtual void print(std::ostream &os=std::cout, int endline=1) const
Definition: HyperPoint.cpp:453
bool allLT(const HyperPoint &other) const
Definition: HyperPoint.cpp:336
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
#define ERROR_LOG
int _dimension
Definition: HyperCuboid.h:32
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ HyperCuboid() [3/3]

HyperCuboid::HyperCuboid ( int  dimension,
double  low,
double  high 
)

Construct the HyperCuboid with two HyperPoints (x, x, x ....) and (y, y, y ....)

Definition at line 35 of file HyperCuboid.cpp.

35  :
36  _dimension ( dimension ),
37  _lowCorner ( dimension ), //note this assignment sets the dimension of this variable forever, so if
38  _highCorner( dimension ) //low and high corners are a different size, an error will be thrown inside HyperPoint
39 {
40 
41  for (int i = 0; i < _dimension; i++){
42  _lowCorner.at(i) = low ;
43  _highCorner.at(i) = high;
44  }
45 
46  if (low > high) {
47  ERROR_LOG << "Your lowCorner isn't lower than your highCorner" << std::endl;
48  }
49 }
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
#define ERROR_LOG
int _dimension
Definition: HyperCuboid.h:32
const double & at(int i) const
Definition: HyperPoint.cpp:433
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ ~HyperCuboid()

HyperCuboid::~HyperCuboid ( )

Destructor

Definition at line 708 of file HyperCuboid.cpp.

708  {
709 }

Member Function Documentation

◆ getBoundaryHyperPlanes()

std::vector< HyperPlane > HyperCuboid::getBoundaryHyperPlanes ( ) const

Get all the HyperPlanes that define the ‘faces’ of the HyperCuboid. Note that nDim points are needed to define such HyperPlanes.

e.g. for a square the 'faces' are lines defined by 2 points for a cube the 'faces' are planes defined by 3 points

Definition at line 252 of file HyperCuboid.cpp.

252  {
253 
254  //Get all the verticies of the HyperCuboid, then find all the HyperPlanes
255  //that are conected to these verticies.
256  std::vector<HyperPlane> planes = getConnectedHyperPlanes(getVertices());
257  std::vector<int> isUnique(planes.size(), 1);
258 
259 
260  //remove all the duplicates.
261 
262  VERBOSE_LOG << "There are " << planes.size() << " planes before removing doubles";
263 
264 
265  for(unsigned j = 0; j < planes.size(); j++){
266 
267  if (isUnique.at(j) == 0){ VERBOSE_LOG << " Skippied"; continue; }
268 
269  for(unsigned i = j+1; i < planes.size(); i++){
270 
271  if (isUnique.at(i) == 0) continue;
272  if (planes.at(i) == planes.at(j)) isUnique.at(i) = 0;
273 
274  }
275  }
276 
277  std::vector<HyperPlane> faces;
278  for(unsigned j = 0; j < planes.size(); j++){
279  if (isUnique.at(j) == 1) faces.push_back(planes.at(j));
280  }
281 
282 
283  VERBOSE_LOG << "There are " << faces.size() << " planes after removing doubles";
284 
285 
286  return faces;
287 
288 }
HyperPointSet getVertices() const
#define VERBOSE_LOG
std::vector< HyperPlane > getConnectedHyperPlanes(const HyperPoint &point) const

◆ getCenter()

HyperPoint HyperCuboid::getCenter ( ) const

Get the HyperPoint at the center of the HyperCuboid

Definition at line 93 of file HyperCuboid.cpp.

93  {
94  return (_lowCorner + _highCorner)*0.5;
95 }
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ getConnectedHyperPlanes() [1/2]

std::vector< HyperPlane > HyperCuboid::getConnectedHyperPlanes ( const HyperPoint point) const

Give it a corner of the HyperCuboid and it will return all faces (HyperPlanes) connected to that corner. Note that nDim points are needed to define such a HyperPlane.

e.g. for a square the 'faces' are lines defined by 2 points for a cube the 'faces' are planes defined by 3 points

Definition at line 197 of file HyperCuboid.cpp.

197  {
198 
199  std::vector<HyperPlane> connectedHyperPlanes;
200 
201  //First find all the verticies that are connected to this one by an edge.
202  //There will be nDim such verticies
203  int dim = getDimension();
204  HyperPointSet connectedVerticies = getConnectedVerticies(point);
205 
206  //We now have the vertex given, and an additional nDim connected
207  //verticies. There is therefore nDim possible Hyperplanes one can form.
208  for (int i = 0; i < dim; i++){
209  HyperPointSet pointsInPlane(dim);
210  pointsInPlane.push_back(point);
211  for(int j = 0; j < dim; j++){
212  if (i != j) pointsInPlane.push_back(connectedVerticies.at(j));
213  }
214  pointsInPlane.sort();
215  HyperPlane plane(pointsInPlane);
216  connectedHyperPlanes.push_back(plane);
217  }
218 
219  return connectedHyperPlanes;
220 
221 }
HyperPointSet getConnectedVerticies(const HyperPointSet &pointSet) const
const int & getDimension() const
Definition: HyperCuboid.h:45
const HyperPoint & at(int i) const

◆ getConnectedHyperPlanes() [2/2]

std::vector< HyperPlane > HyperCuboid::getConnectedHyperPlanes ( const HyperPointSet point) const

Give it a corners of the HyperCuboid and it will return all faces (HyperPlanes) connected to that corner. Note that nDim points are needed to define such a HyperPlane.

e.g. for a square the 'faces' are lines defined by 2 points for a cube the 'faces' are planes defined by 3 points

This is done for all corners given in the HyperPointSet

Definition at line 231 of file HyperCuboid.cpp.

231  {
232 
233  std::vector<HyperPlane> connectedHyperPlanes;
234 
235  for(unsigned i = 0; i < point.size(); i++){
236  std::vector<HyperPlane> someHyperPlanes = getConnectedHyperPlanes(point.at(i));
237  for(unsigned j = 0; j < someHyperPlanes.size(); j++){
238  connectedHyperPlanes.push_back(someHyperPlanes.at(j));
239  }
240  }
241 
242  return connectedHyperPlanes;
243 
244 }
const HyperPoint & at(int i) const
unsigned int size() const
std::vector< HyperPlane > getConnectedHyperPlanes(const HyperPoint &point) const

◆ getConnectedVerticies() [1/2]

HyperPointSet HyperCuboid::getConnectedVerticies ( const HyperPointSet pointSet) const

If a vertex of the HyperCuboid is given, this finds all other verticies that are connected to that one by an edge. It does this for all HyperPoints in the HyperPointSet given.

For example, if you give it the top right corner of a square, it will return the top left and bottom right corners.

Definition at line 521 of file HyperCuboid.cpp.

521  {
522 
523  HyperPointSet hyperPointSet(getDimension());
524 
525  for (unsigned int i = 0; i < pointSet.size(); i++){
526  hyperPointSet.addHyperPointSet ( getConnectedVerticies(pointSet.at(i)) );
527  VERBOSE_LOG << "Sorting....";
528  hyperPointSet.sort();
529  VERBOSE_LOG << "Removing Duplicates....";
530  hyperPointSet.removeDuplicates();
531  }
532 
533  return hyperPointSet;
534 }
HyperPointSet getConnectedVerticies(const HyperPointSet &pointSet) const
#define VERBOSE_LOG
const int & getDimension() const
Definition: HyperCuboid.h:45
const HyperPoint & at(int i) const
unsigned int size() const

◆ getConnectedVerticies() [2/2]

HyperPointSet HyperCuboid::getConnectedVerticies ( const HyperPoint point) const

If a vertex of the HyperCuboid is given, this finds all other verticies that are connected to that one by an edge

For example, if you give it the top right corner of a square, it will return the top left and bottom right corners.

Definition at line 541 of file HyperCuboid.cpp.

541  {
542 
543  int dim = getDimension();
544 
545  HyperPointSet hyperPointSet(dim);
546 
547  HyperPoint oppositePoint = getOppositePoint(point);
548  HyperPoint vectorToOpposite = oppositePoint - point;
549 
550  for (int i = 0; i < dim; i++){
551  HyperPoint translation(dim);
552  translation.at(i) = vectorToOpposite.at(i);
553  HyperPoint newCorner = point + translation;
554  hyperPointSet.push_back(newCorner);
555  }
556 
557  return hyperPointSet;
558 
559 }
HyperPoint getOppositePoint(const HyperPoint &point) const
const int & getDimension() const
Definition: HyperCuboid.h:45
const double & at(int i) const
Definition: HyperPoint.cpp:433

◆ getDimension()

const int& HyperCuboid::getDimension ( ) const
inline

get the dimensionality

Definition at line 45 of file HyperCuboid.h.

◆ getEdgeCenters()

HyperPointSet HyperCuboid::getEdgeCenters ( ) const

Definition at line 416 of file HyperCuboid.cpp.

416  {
417 
418  int ndim = getDimension();
419 
420  std::bitset< 15 > binary( 0 );
421 
422  HyperPoint center = getCenter();
423  HyperPoint vectorToHighCorner = _highCorner - center;
424 
425  int nVertices = pow(2, ndim);
426 
427  HyperPointSet verticies(ndim);
428 
429  for (int dimToIgnore = 0; dimToIgnore < ndim; dimToIgnore++){
430 
431  for (int i = 0; i < nVertices; i++){
432  HyperPoint vectorToVertex(vectorToHighCorner);
433  binary = i;
434  for (int dim = 0; dim < ndim; dim++){
435  if (binary[dim] == 0){
436  vectorToVertex.at(dim) = -vectorToVertex.at(dim);
437  }
438  if (dimToIgnore == dim){
439  vectorToVertex.at(dim) = 0.0;
440  }
441  }
442  verticies.push_back(vectorToVertex + center);
443  }
444  }
445 
446  verticies.sort();
447  verticies.removeDuplicates();
448 
449  return verticies;
450 
451 }
const int & getDimension() const
Definition: HyperCuboid.h:45
HyperPoint getCenter() const
Definition: HyperCuboid.cpp:93
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ getHighCorner() [1/2]

const HyperPoint& HyperCuboid::getHighCorner ( ) const
inline

return the high HyperPoint corner

Definition at line 89 of file HyperCuboid.h.

◆ getHighCorner() [2/2]

HyperPoint& HyperCuboid::getHighCorner ( )
inline

return the high HyperPoint corner

Definition at line 93 of file HyperCuboid.h.

◆ getLowCorner() [1/2]

const HyperPoint& HyperCuboid::getLowCorner ( ) const
inline

return the low HyperPoint corner

Definition at line 87 of file HyperCuboid.h.

◆ getLowCorner() [2/2]

HyperPoint& HyperCuboid::getLowCorner ( )
inline

return the low HyperPoint corner

Definition at line 91 of file HyperCuboid.h.

◆ getNegativeIntersectionParameter()

double HyperCuboid::getNegativeIntersectionParameter ( const HyperLine line) const

A HyperLine is parameterised by (v_1 + x.v_2). This finds one of the two points, x_-, where the HyperLine intersects a face of the HyperCuboid.

Definition at line 352 of file HyperCuboid.cpp.

352  {
353 
354  updateFaceCash();
355 
356  int foundSolution = 0;
357  double negativeLineParam = 0.0;
358 
359  for(unsigned i = 0; i < _faces.size(); i++){
360  HyperPoint LineParam = _faces.at(i).findLineIntersectionParameter(line);
361  HyperPoint PlaneParam = _faces.at(i).findPlaneIntersectionParameters(line);
362 
363  VERBOSE_LOG << "-----------------------" << i << "--------------------------";
364  VERBOSE_LOG << "Get the parameters for the line and the plane";
365 
366  if (LineParam.getDimension()==0){
367  VERBOSE_LOG << "Matrix is singular...";
368  continue;
369  }
370 
371  if (PlaneParam <= 1.0 && PlaneParam >= 0.0) {
372  VERBOSE_LOG << "This intersection is within the cuboid";
373  if(LineParam < 0 && foundSolution == 1){
374  double otherPoint = LineParam.at(0);
375  double diff = otherPoint - negativeLineParam;
376  if (fabs(diff)>10e-2) ERROR_LOG << "Somehow there are two distinct negative intercepts";
377  else ERROR_LOG << "Already have this solution... weird";
378  }
379  else if(LineParam < 0) {
380  VERBOSE_LOG << "This positive intersection point " << LineParam.at(0);
381 
382  negativeLineParam = LineParam.at(0);
383  foundSolution = 1;
384  }
385  else{
386  VERBOSE_LOG << "This positive intersection point" << LineParam.at(0);
387  }
388  }
389  else{
390  VERBOSE_LOG << "This intersection is not within the cuboid";
391  }
392 
393  }
394 
395  if (foundSolution == 0) ERROR_LOG << "Found no intercept in cuboid.";
396 
397  return negativeLineParam;
398 }
#define ERROR_LOG
#define VERBOSE_LOG
void updateFaceCash() const
std::vector< HyperPlane > _faces
Definition: HyperCuboid.h:39
const double & at(int i) const
Definition: HyperPoint.cpp:433
int getDimension() const
Definition: HyperPoint.h:99

◆ getNegativeIntersectionPoint()

HyperPoint HyperCuboid::getNegativeIntersectionPoint ( const HyperLine line) const

A HyperLine is parameterised by (v_1 + x.v_2). This finds one of the two points, (v_1 + x_-.v_2), where the HyperLine intersects a face of the HyperCuboid

Definition at line 410 of file HyperCuboid.cpp.

410  {
411 
413 
414 }
double getNegativeIntersectionParameter(const HyperLine &line) const
HyperPoint getParametricPoint(const HyperPoint &t) const
Definition: NPlane.cpp:40

◆ getOppositePoint()

HyperPoint HyperCuboid::getOppositePoint ( const HyperPoint point) const

Get point on the opposite side of the HyperCuboid

Imagine a vector V going from the center of the HyperCuboid, C, to the given point. This returns C - V

Definition at line 158 of file HyperCuboid.cpp.

158  {
159 
160  HyperPoint shift = point - _lowCorner;
161  HyperPoint opposite = _highCorner - shift;
162 
163  return opposite;
164 }
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ getPositiveIntersectionParameter()

double HyperCuboid::getPositiveIntersectionParameter ( const HyperLine line) const

A HyperLine is parameterised by (v_1 + x.v_2). This finds one of the two points, x_+, where the HyperLine intersects a face of the HyperCuboid

Definition at line 301 of file HyperCuboid.cpp.

301  {
302 
303  updateFaceCash();
304 
305  int foundSolution = 0;
306  double negativeLineParam = 0.0;
307 
308  for(unsigned i = 0; i < _faces.size(); i++){
309  HyperPoint LineParam = _faces.at(i).findLineIntersectionParameter(line);
310  HyperPoint PlaneParam = _faces.at(i).findPlaneIntersectionParameters(line);
311 
312  VERBOSE_LOG << "-----------------------" << i << "--------------------------";
313  VERBOSE_LOG << "Get the parameters for the line and the plane";
314 
315  if (LineParam.getDimension()==0){
316  VERBOSE_LOG << "Matrix is singular...";
317  continue;
318  }
319 
320  if (PlaneParam <= 1.0 && PlaneParam >= 0.0) {
321  VERBOSE_LOG << "This intersection is within the cuboid";
322  if(LineParam > 0 && foundSolution == 1){
323  double otherPoint = LineParam.at(0);
324  double diff = otherPoint - negativeLineParam;
325  if (fabs(diff)>10e-2) ERROR_LOG << "Somehow there are two distinct negative intercepts";
326  else ERROR_LOG << "Already have this solution... weird";
327  }
328  else if(LineParam > 0) {
329  VERBOSE_LOG << "This positive intersection point " << LineParam.at(0);
330 
331  negativeLineParam = LineParam.at(0);
332  foundSolution = 1;
333  }
334  else{
335  VERBOSE_LOG << "This positive intersection point" << LineParam.at(0);
336  }
337  }
338  else{
339  VERBOSE_LOG << "This intersection is not within the cuboid";
340  }
341 
342  }
343 
344  if (foundSolution == 0) ERROR_LOG << "Found no intercept in cuboid.";
345 
346  return negativeLineParam;
347 
348 }
#define ERROR_LOG
#define VERBOSE_LOG
void updateFaceCash() const
std::vector< HyperPlane > _faces
Definition: HyperCuboid.h:39
const double & at(int i) const
Definition: HyperPoint.cpp:433
int getDimension() const
Definition: HyperPoint.h:99

◆ getPositiveIntersectionPoint()

HyperPoint HyperCuboid::getPositiveIntersectionPoint ( const HyperLine line) const

A HyperLine is parameterised by (v_1 + x.v_2). This finds one of the two points, (v_1 + x_+.v_2), where the HyperLine intersects a face of the HyperCuboid

Definition at line 402 of file HyperCuboid.cpp.

402  {
403 
405 
406 }
double getPositiveIntersectionParameter(const HyperLine &line) const
HyperPoint getParametricPoint(const HyperPoint &t) const
Definition: NPlane.cpp:40

◆ getRandomPoint()

HyperPoint HyperCuboid::getRandomPoint ( TRandom *  random = gRandom) const

Get a random point in the HyperCuboid (uses gRandom)

Definition at line 168 of file HyperCuboid.cpp.

168  {
169 
170  HyperPoint point(getDimension());
171  for (int i = 0; i < getDimension(); i++){
172  point.at(i) = random->Uniform(getLowCorner().at(i), getHighCorner().at(i));
173  }
174  return point;
175 
176 }
const int & getDimension() const
Definition: HyperCuboid.h:45
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87

◆ getRandomPoints()

HyperPointSet HyperCuboid::getRandomPoints ( int  nPoints = 100,
TRandom *  random = gRandom 
) const

Get a random point in the HyperCuboid (uses gRandom)

Definition at line 180 of file HyperCuboid.cpp.

180  {
181 
182  HyperPointSet points(getDimension());
183  for (int i = 0; i < nPoints; i++){
184  points.push_back( getRandomPoint(random) );
185  }
186  return points;
187 
188 }
HyperPoint getRandomPoint(TRandom *random=gRandom) const
const int & getDimension() const
Definition: HyperCuboid.h:45

◆ getVertices()

HyperPointSet HyperCuboid::getVertices ( ) const

Get all verticies of the HyperCuboid with no repeats.

This is done by starting from one corner and following the edges to the other corners. This has to be done nDim times in order to get all the corners.

Definition at line 461 of file HyperCuboid.cpp.

461  {
462 
463  //New faster method. We know the number of verticies, so just
464  //loop from 0 -> nVertex-1 and convert this number to binary.
465  //Imagine the binary number is a vector V.
466  //Also have the center of the cube, C, and a vector to the top right
467  //corner T.
468  //
469  //
470 
471  int ndim = getDimension();
472 
473  std::bitset< 15 > binary( 0 );
474 
475  HyperPoint center = getCenter();
476  HyperPoint vectorToHighCorner = _highCorner - center;
477 
478  int nVertices = pow(2, ndim);
479 
480  HyperPointSet verticies(ndim);
481 
482  for (int i = 0; i < nVertices; i++){
483  HyperPoint vectorToVertex(vectorToHighCorner);
484  binary = i;
485  for (int dim = 0; dim < ndim; dim++){
486  if (binary[dim] == 0){
487  vectorToVertex.at(dim) = -vectorToVertex.at(dim);
488  }
489  }
490  verticies.push_back(vectorToVertex + center);
491  }
492 
493  return verticies;
494 
495  //OLD method
496  //HyperPointSet hyperPointSet(getDimension());
497  //hyperPointSet.push_back(_lowCorner);
498  //
499  //HyperPointSet previousHyperPointSet = hyperPointSet;
500 
501  //for(int i = 1; i < getDimension(); i++){
502  // previousHyperPointSet = getConnectedVerticies(previousHyperPointSet);
503  // hyperPointSet.addHyperPointSet(previousHyperPointSet);
504  // hyperPointSet.sort();
505  // hyperPointSet.removeDuplicates();
506  //}
507  //
508  //hyperPointSet.push_back(_highCorner);
509 
510 
511  //return hyperPointSet;
512 
513 }
const int & getDimension() const
Definition: HyperCuboid.h:45
HyperPoint getCenter() const
Definition: HyperCuboid.cpp:93
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ getWidth() [1/2]

HyperPoint HyperCuboid::getWidth ( ) const

Find width of the HyperCuboid as a HyperPoint

Definition at line 611 of file HyperCuboid.cpp.

611  {
612  return _highCorner - _lowCorner;
613 }
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ getWidth() [2/2]

double HyperCuboid::getWidth ( int  dim) const

Find the width of the HyperCuboid in a given dimension

Definition at line 617 of file HyperCuboid.cpp.

617  {
618  return _highCorner.at(dim) - _lowCorner.at(dim);
619 }
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
const double & at(int i) const
Definition: HyperPoint.cpp:433
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ inflateCuboid()

const HyperCuboid & HyperCuboid::inflateCuboid ( double  percent)

Inflate the boundaries of the HyperCuboid by some percentage.

x_low_0' = x_low_0 - (x_high_0 - x_low_0) * percent

x_high_0' = x_high_0 + (x_high_0 - x_low_0) * percent

Definition at line 80 of file HyperCuboid.cpp.

80  {
81 
82  for (int i = 0; i < getDimension(); i++){
83  double diff = getHighCorner().at(i) - getLowCorner().at(i);
84  double increase = diff*percent;
85  getHighCorner().at(i) = getHighCorner().at(i) + increase;
86  getLowCorner() .at(i) = getLowCorner() .at(i) - increase;
87  }
88  return *this;
89 }
const int & getDimension() const
Definition: HyperCuboid.h:45
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const double & at(int i) const
Definition: HyperPoint.cpp:433
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87

◆ inVolume() [1/2]

bool HyperCuboid::inVolume ( const HyperPoint coords) const

See if a HyperPoint is within the HyperCuboid volume

Definition at line 578 of file HyperCuboid.cpp.

578  {
579 
580  if (_lowCorner.allLT(coords) && _highCorner.allGTOE(coords)) return 1;
581  return 0;
582 
583 }
bool allLT(const HyperPoint &other) const
Definition: HyperPoint.cpp:336
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
HyperPoint _highCorner
Definition: HyperCuboid.h:35
bool allGTOE(const HyperPoint &other) const
Definition: HyperPoint.cpp:369

◆ inVolume() [2/2]

bool HyperCuboid::inVolume ( const HyperPoint coords,
std::vector< int >  dims 
) const

See if a HyperPoint is within the HyperCuboid volume, but only for selected dimensions.

Definition at line 587 of file HyperCuboid.cpp.

587  {
588 
589  for (unsigned i = 0; i < dims.size(); i++){
590  int dim = dims.at(i);
591  double minEdge = getLowCorner ().at(dim);
592  double maxEdge = getHighCorner().at(dim);
593  double val = coords.at(dim);
594  if ( ( minEdge < val && val <= maxEdge ) == false ) return false;
595  }
596 
597  return true;
598 
599 }
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const double & at(int i) const
Definition: HyperPoint.cpp:433
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87

◆ operator !=()

bool HyperCuboid::operator != ( const HyperCuboid other) const

See if two HyperCuboids are not the same

Definition at line 65 of file HyperCuboid.cpp.

65  {
66  if (other.getDimension() != this->getDimension()) {
67  ERROR_LOG << "Trying to compare HyperCuboids of different dimensions, returning false";
68  return false;
69  }
70  if (getLowCorner() != other.getLowCorner() ) return true;
71  if (getHighCorner() != other.getHighCorner()) return true;
72  return false;
73 }
#define ERROR_LOG
const int & getDimension() const
Definition: HyperCuboid.h:45
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87

◆ operator==()

bool HyperCuboid::operator== ( const HyperCuboid other) const

See if two HyperCuboids are the same

Definition at line 53 of file HyperCuboid.cpp.

53  {
54  if (other.getDimension() != this->getDimension()) {
55  ERROR_LOG << "Trying to compare HyperCuboids of different dimensions, returning false";
56  return false;
57  }
58  if (getLowCorner() != other.getLowCorner() ) return false;
59  if (getHighCorner() != other.getHighCorner()) return false;
60  return true;
61 }
#define ERROR_LOG
const int & getDimension() const
Definition: HyperCuboid.h:45
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87

◆ print()

void HyperCuboid::print ( std::ostream &  os = std::cout,
int  endline = 1 
) const

Print the HyperCuboid to given std::ostream

Definition at line 99 of file HyperCuboid.cpp.

99  {
100 
101  os << "Lower Corner: ";
102  _lowCorner.print(os, 0);
103  os << " High Corner: ";
104  _highCorner.print(os, 0);
105  if (endline) os << std::endl;
106 
107 }
virtual void print(std::ostream &os=std::cout, int endline=1) const
Definition: HyperPoint.cpp:453
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ project()

HyperCuboid HyperCuboid::project ( std::vector< int >  dims) const

Project the HyperCuboid into a lower dimensional space. E.g. start with HyperCuboid defined by (0,-1,-2) , (0,+1,+2) and project over dimensions 0 and 2. This would return a HyperCuboid defined by (0,-2) , (0,+2)

Definition at line 113 of file HyperCuboid.cpp.

113  {
114 
115  int newdim = (int)dims.size();
116  HyperPoint lowCorner (newdim);
117  HyperPoint highCorner(newdim);
118 
119  for (int i = 0; i < newdim; i++){
120  lowCorner .at(i) = getLowCorner ().at( dims.at(i) );
121  highCorner.at(i) = getHighCorner().at( dims.at(i) );
122  }
123 
124  return HyperCuboid(lowCorner, highCorner);
125 
126 }
HyperCuboid(int dimension)
Definition: HyperCuboid.cpp:6
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const double & at(int i) const
Definition: HyperPoint.cpp:433
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87

◆ projectOpposite()

HyperCuboid HyperCuboid::projectOpposite ( std::vector< int >  dims) const

Project the HyperCuboid into a lower dimensional space. E.g. start with HyperCuboid defined by (0,-1,-2) , (0,+1,+2) and projectOpposite over dimensions 1. This would return a HyperCuboid defined by (0,-2) , (0,+2)

Definition at line 132 of file HyperCuboid.cpp.

132  {
133 
134  int currentDim = getDimension();
135  int newdim = (int)dims.size();
136 
137  std::vector<int> projdims;
138 
139  for (int i = 0; i < currentDim; i++){
140  bool doesExist = false;
141  for (int j = 0; j < newdim; j++){
142  int dim = dims.at(j);
143  if (i == dim) doesExist = true;
144  }
145 
146  if (doesExist == false) projdims.push_back(i);
147  }
148 
149  return project(projdims);
150 
151 }
const int & getDimension() const
Definition: HyperCuboid.h:45
HyperCuboid project(std::vector< int > dims) const

◆ setCorners()

bool HyperCuboid::setCorners ( const HyperPoint lowCorner,
const HyperPoint highCorner 
)

Set the upper and lower corners of the HyperCuboid

Definition at line 563 of file HyperCuboid.cpp.

563  {
564 
565  if (lowCorner.allLTOE(highCorner)){
566  _lowCorner = lowCorner;
567  _highCorner = highCorner;
568  }
569  else{
570  ERROR_LOG << "Your lowCorner isn't lower than your highCorner" <<std::endl;
571  return 0;
572  }
573  return 1;
574 }
bool allLTOE(const HyperPoint &other) const
Definition: HyperPoint.cpp:358
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
#define ERROR_LOG
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ split() [1/2]

HyperVolume HyperCuboid::split ( int  dimension,
double  fractionalSplitPoint 
) const

split the cuboid into two along the dimension given and return the resulting HyperCuboids in a HyperCuboidSet. The fractional split point [0,1] decides where (in that dimesnion) the split is

Definition at line 687 of file HyperCuboid.cpp.

687  {
688 
689  return HyperVolume(
690  splitBelow(dimension,fractionalSplitPoint),
691  splitAbove(dimension,fractionalSplitPoint)
692  );
693 
694 }
HyperCuboid splitAbove(int dimension, double fractionalSplitPoint) const
HyperCuboid splitBelow(int dimension, double fractionalSplitPoint) const

◆ split() [2/2]

void HyperCuboid::split ( int  dimension,
double  fractionalSplitPoint,
HyperVolume set 
) const

split the cuboid into two along the dimension given and append the resulting HyperCuboids to the HyperCuboidSet given. The fractional split point [0,1] decides where (in that dimesnion) the split is

Definition at line 699 of file HyperCuboid.cpp.

699  {
700 
701  set.push_back( splitBelow(dimension,fractionalSplitPoint) );
702  set.push_back( splitAbove(dimension,fractionalSplitPoint) );
703 
704 }
void push_back(const HyperCuboid &hyperCuboid)
HyperCuboid splitAbove(int dimension, double fractionalSplitPoint) const
HyperCuboid splitBelow(int dimension, double fractionalSplitPoint) const

◆ splitAbove()

HyperCuboid HyperCuboid::splitAbove ( int  dimension,
double  fractionalSplitPoint 
) const

split the cuboid into two along the dimension given and return the resulting HyperCuboid. The fractional split point [0,1] decides where (in that dimesnion) the split is

Definition at line 656 of file HyperCuboid.cpp.

656  {
657 
658  if (dimension < 0 || dimension >= getDimension()){
659  ERROR_LOG << "You cannot split in a dimension that doesn't exist!!" << std::endl;
660  return HyperCuboid(*this);
661  }
662  if (fractionalSplitPoint <= 0.0 || fractionalSplitPoint >= 1.0){
663  ERROR_LOG << "Your fractional split point must be between 0.0 and 1.0" << std::endl;
664  return HyperCuboid(*this);
665  }
666 
667  HyperPoint lowCorner2 (_lowCorner );
668  HyperPoint highCorner2(_highCorner);
669 
670  double low = _lowCorner .at(dimension);
671  double high = _highCorner.at(dimension);
672  double width = high - low;
673 
674  double splitCoord = low + width*fractionalSplitPoint;
675 
676  lowCorner2 .at(dimension) = splitCoord;
677 
678  HyperCuboid highCuboid(lowCorner2, highCorner2);
679 
680  return highCuboid;
681 
682 }
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
#define ERROR_LOG
HyperCuboid(int dimension)
Definition: HyperCuboid.cpp:6
const int & getDimension() const
Definition: HyperCuboid.h:45
const double & at(int i) const
Definition: HyperPoint.cpp:433
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ splitBelow()

HyperCuboid HyperCuboid::splitBelow ( int  dimension,
double  fractionalSplitPoint 
) const

split the cuboid into two along the dimension given and return the resulting HyperCuboid. The fractional split point [0,1] decides where (in that dimesnion) the split is

Definition at line 625 of file HyperCuboid.cpp.

625  {
626 
627  if (dimension < 0 || dimension >= getDimension()){
628  ERROR_LOG << "You cannot split in a dimension that doesn't exist!!" << std::endl;
629  return HyperCuboid(*this);
630  }
631  if (fractionalSplitPoint <= 0.0 || fractionalSplitPoint >= 1.0){
632  ERROR_LOG << "Your fractional split point must be between 0.0 and 1.0" << std::endl;
633  return HyperCuboid(*this);
634  }
635 
636  HyperPoint lowCorner1 (_lowCorner );
637  HyperPoint highCorner1(_highCorner);
638 
639  double low = _lowCorner .at(dimension);
640  double high = _highCorner.at(dimension);
641  double width = high - low;
642 
643  double splitCoord = low + width*fractionalSplitPoint;
644 
645  highCorner1.at(dimension) = splitCoord;
646 
647  HyperCuboid lowCuboid (lowCorner1, highCorner1);
648 
649  return lowCuboid;
650 
651 }
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
#define ERROR_LOG
HyperCuboid(int dimension)
Definition: HyperCuboid.cpp:6
const int & getDimension() const
Definition: HyperCuboid.h:45
const double & at(int i) const
Definition: HyperPoint.cpp:433
HyperPoint _highCorner
Definition: HyperCuboid.h:35

◆ updateFaceCash()

void HyperCuboid::updateFaceCash ( ) const
private

It takes a while to find all the HyperPlanes (that define the faces of the HyperCuboid), so they are cashed using this function. Beware if you later change the corners of the HyperCuboid

Definition at line 293 of file HyperCuboid.cpp.

293  {
294 
295  if(_faces.size() == 0) _faces = getBoundaryHyperPlanes();
296 
297 }
std::vector< HyperPlane > _faces
Definition: HyperCuboid.h:39
std::vector< HyperPlane > getBoundaryHyperPlanes() const

◆ volume()

double HyperCuboid::volume ( ) const

Find the volume of the HyperCuboid

Definition at line 603 of file HyperCuboid.cpp.

603  {
604 
605  return (_highCorner - _lowCorner).multiplyElements();
606 
607 }
HyperPoint _lowCorner
Definition: HyperCuboid.h:34
HyperPoint _highCorner
Definition: HyperCuboid.h:35

Member Data Documentation

◆ _dimension

int HyperCuboid::_dimension
private

The dimensionality of the cuboid

Definition at line 32 of file HyperCuboid.h.

◆ _faces

std::vector<HyperPlane> HyperCuboid::_faces
mutableprivate

The HyperPlanes that define the faces of the cuboid. Dy default these are not filled, but if needed it's useful to cashe them here

Definition at line 39 of file HyperCuboid.h.

◆ _highCorner

HyperPoint HyperCuboid::_highCorner
private

The higher corner of the cuboid

Definition at line 35 of file HyperCuboid.h.

◆ _lowCorner

HyperPoint HyperCuboid::_lowCorner
private

The lower corner of the cuboid

Definition at line 34 of file HyperCuboid.h.


The documentation for this class was generated from the following files: