7 _dimension ( dimension ),
8 _lowCorner ( dimension ),
9 _highCorner( dimension )
16 _dimension( lowCorner.size() ),
17 _lowCorner ( _dimension ),
18 _highCorner( _dimension )
21 if (lowCorner.
allLT(highCorner)){
26 ERROR_LOG <<
"Your lowCorner isn't lower than your highCorner"<< std::endl;
36 _dimension ( dimension ),
37 _lowCorner ( dimension ),
38 _highCorner( dimension )
47 ERROR_LOG <<
"Your lowCorner isn't lower than your highCorner" << std::endl;
55 ERROR_LOG <<
"Trying to compare HyperCuboids of different dimensions, returning false";
67 ERROR_LOG <<
"Trying to compare HyperCuboids of different dimensions, returning false";
84 double increase = diff*percent;
101 os <<
"Lower Corner: ";
103 os <<
" High Corner: ";
105 if (endline) os << std::endl;
115 int newdim = (int)dims.size();
119 for (
int i = 0; i < newdim; i++){
135 int newdim = (int)dims.size();
137 std::vector<int> projdims;
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;
146 if (doesExist ==
false) projdims.push_back(i);
183 for (
int i = 0; i < nPoints; i++){
199 std::vector<HyperPlane> connectedHyperPlanes;
208 for (
int i = 0; i < dim; i++){
211 for(
int j = 0; j < dim; j++){
212 if (i != j) pointsInPlane.
push_back(connectedVerticies.
at(j));
214 pointsInPlane.
sort();
216 connectedHyperPlanes.push_back(plane);
219 return connectedHyperPlanes;
233 std::vector<HyperPlane> connectedHyperPlanes;
235 for(
unsigned i = 0; i < point.
size(); i++){
237 for(
unsigned j = 0; j < someHyperPlanes.size(); j++){
238 connectedHyperPlanes.push_back(someHyperPlanes.at(j));
242 return connectedHyperPlanes;
257 std::vector<int> isUnique(planes.size(), 1);
262 VERBOSE_LOG <<
"There are " << planes.size() <<
" planes before removing doubles";
265 for(
unsigned j = 0; j < planes.size(); j++){
267 if (isUnique.at(j) == 0){
VERBOSE_LOG <<
" Skippied";
continue; }
269 for(
unsigned i = j+1; i < planes.size(); i++){
271 if (isUnique.at(i) == 0)
continue;
272 if (planes.at(i) == planes.at(j)) isUnique.at(i) = 0;
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));
283 VERBOSE_LOG <<
"There are " << faces.size() <<
" planes after removing doubles";
305 int foundSolution = 0;
306 double negativeLineParam = 0.0;
308 for(
unsigned i = 0; i <
_faces.size(); i++){
312 VERBOSE_LOG <<
"-----------------------" << i <<
"--------------------------";
313 VERBOSE_LOG <<
"Get the parameters for the line and the plane";
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";
328 else if(LineParam > 0) {
329 VERBOSE_LOG <<
"This positive intersection point " << LineParam.
at(0);
331 negativeLineParam = LineParam.
at(0);
335 VERBOSE_LOG <<
"This positive intersection point" << LineParam.
at(0);
339 VERBOSE_LOG <<
"This intersection is not within the cuboid";
344 if (foundSolution == 0)
ERROR_LOG <<
"Found no intercept in cuboid.";
346 return negativeLineParam;
356 int foundSolution = 0;
357 double negativeLineParam = 0.0;
359 for(
unsigned i = 0; i <
_faces.size(); i++){
363 VERBOSE_LOG <<
"-----------------------" << i <<
"--------------------------";
364 VERBOSE_LOG <<
"Get the parameters for the line and the plane";
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";
379 else if(LineParam < 0) {
380 VERBOSE_LOG <<
"This positive intersection point " << LineParam.
at(0);
382 negativeLineParam = LineParam.
at(0);
386 VERBOSE_LOG <<
"This positive intersection point" << LineParam.
at(0);
390 VERBOSE_LOG <<
"This intersection is not within the cuboid";
395 if (foundSolution == 0)
ERROR_LOG <<
"Found no intercept in cuboid.";
397 return negativeLineParam;
420 std::bitset< 15 > binary( 0 );
425 int nVertices = pow(2, ndim);
429 for (
int dimToIgnore = 0; dimToIgnore < ndim; dimToIgnore++){
431 for (
int i = 0; i < nVertices; i++){
432 HyperPoint vectorToVertex(vectorToHighCorner);
434 for (
int dim = 0; dim < ndim; dim++){
435 if (binary[dim] == 0){
436 vectorToVertex.
at(dim) = -vectorToVertex.
at(dim);
438 if (dimToIgnore == dim){
439 vectorToVertex.
at(dim) = 0.0;
442 verticies.
push_back(vectorToVertex + center);
473 std::bitset< 15 > binary( 0 );
478 int nVertices = pow(2, ndim);
482 for (
int i = 0; i < nVertices; i++){
483 HyperPoint vectorToVertex(vectorToHighCorner);
485 for (
int dim = 0; dim < ndim; dim++){
486 if (binary[dim] == 0){
487 vectorToVertex.
at(dim) = -vectorToVertex.
at(dim);
490 verticies.
push_back(vectorToVertex + center);
525 for (
unsigned int i = 0; i < pointSet.
size(); i++){
528 hyperPointSet.
sort();
533 return hyperPointSet;
548 HyperPoint vectorToOpposite = oppositePoint - point;
550 for (
int i = 0; i < dim; i++){
552 translation.
at(i) = vectorToOpposite.
at(i);
557 return hyperPointSet;
565 if (lowCorner.
allLTOE(highCorner)){
570 ERROR_LOG <<
"Your lowCorner isn't lower than your highCorner" <<std::endl;
589 for (
unsigned i = 0; i < dims.size(); i++){
590 int dim = dims.at(i);
593 double val = coords.
at(dim);
594 if ( ( minEdge < val && val <= maxEdge ) ==
false )
return false;
628 ERROR_LOG <<
"You cannot split in a dimension that doesn't exist!!" << std::endl;
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;
641 double width = high - low;
643 double splitCoord = low + width*fractionalSplitPoint;
645 highCorner1.
at(dimension) = splitCoord;
659 ERROR_LOG <<
"You cannot split in a dimension that doesn't exist!!" << std::endl;
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;
672 double width = high - low;
674 double splitCoord = low + width*fractionalSplitPoint;
676 lowCorner2 .
at(dimension) = splitCoord;
bool allLTOE(const HyperPoint &other) const
HyperPointSet getVertices() const
HyperPoint getRandomPoint(TRandom *random=gRandom) const
virtual void print(std::ostream &os=std::cout, int endline=1) const
HyperPoint getOppositePoint(const HyperPoint &point) const
void push_back(const HyperCuboid &hyperCuboid)
HyperCuboid splitAbove(int dimension, double fractionalSplitPoint) const
bool allLT(const HyperPoint &other) const
HyperPointSet getConnectedVerticies(const HyperPointSet &pointSet) const
HyperPoint getNegativeIntersectionPoint(const HyperLine &line) const
double getNegativeIntersectionParameter(const HyperLine &line) const
HyperPointSet getEdgeCenters() const
HyperCuboid(int dimension)
bool setCorners(const HyperPoint &lowCorner, const HyperPoint &highCorner)
bool operator !=(const HyperCuboid &other) const
const int & getDimension() const
HyperPointSet getRandomPoints(int nPoints=100, TRandom *random=gRandom) const
void updateFaceCash() const
const HyperPoint & at(int i) const
HyperPoint getCenter() const
const HyperPoint & getHighCorner() const
std::vector< HyperPlane > _faces
double getPositiveIntersectionParameter(const HyperLine &line) const
HyperPoint getWidth() const
void print(std::ostream &os=std::cout, int endline=1) const
const double & at(int i) const
HyperPoint getPositiveIntersectionPoint(const HyperLine &line) const
bool operator==(const HyperCuboid &other) const
const HyperPoint & getLowCorner() const
unsigned int size() const
std::vector< HyperPlane > getBoundaryHyperPlanes() const
HyperCuboid splitBelow(int dimension, double fractionalSplitPoint) const
HyperCuboid projectOpposite(std::vector< int > dims) const
std::vector< HyperPlane > getConnectedHyperPlanes(const HyperPoint &point) const
void addHyperPointSet(const HyperPointSet &other)
HyperVolume split(int dimension, double fractionalSplitPoint) const
const HyperCuboid & inflateCuboid(double percent)
HyperCuboid project(std::vector< int > dims) const
void push_back(const HyperPoint &point)
bool allGTOE(const HyperPoint &other) const
HyperPoint getParametricPoint(const HyperPoint &t) const
bool inVolume(const HyperPoint &coords) const