This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/geo/BBox3.h
FrankE a2c9e575a2 huge commit
- worked on about everything
- grid walker using plugable modules
- wifi models
- new distributions
- worked on geometric data-structures
- added typesafe timestamps
- worked on grid-building
- added sensor-classes
- added sensor analysis (step-detection, turn-detection)
- offline data reader
- many test-cases
2016-08-29 08:18:44 +02:00

104 lines
2.1 KiB
C++

#ifndef BBOX3_H
#define BBOX3_H
#include "Point3.h"
class BBox3 {
private:
static constexpr float MAX = +99999;
static constexpr float MIN = -99999;
/** minimum */
Point3 p1;
/** maximum */
Point3 p2;
public:
/** empty ctor */
BBox3() : p1(MAX,MAX,MAX), p2(MIN,MIN,MIN) {;}
/** ctor with min and max */
BBox3(const Point3 min, const Point3 max) : p1(min), p2(max) {;}
/** adjust the bounding-box by adding this point */
void add(const Point3& p) {
if (p.x > p2.x) {p2.x = p.x;}
if (p.y > p2.y) {p2.y = p.y;}
if (p.z > p2.z) {p2.z = p.z;}
if (p.x < p1.x) {p1.x = p.x;}
if (p.y < p1.y) {p1.y = p.y;}
if (p.z < p1.z) {p1.z = p.z;}
}
/** add the given bounding-box to this one */
void add(const BBox3& bb) {
add(bb.getMin());
add(bb.getMax());
}
/** get the bbox's minimum */
const Point3& getMin() const {return p1;}
/** get the bbox's maximum */
const Point3& getMax() const {return p2;}
/** equal? */
bool operator == (const BBox3& o) const {
return (p1.x == o.p1.x) &&
(p1.y == o.p1.y) &&
(p1.z == o.p1.z) &&
(p2.x == o.p2.x) &&
(p2.y == o.p2.y) &&
(p2.z == o.p2.z);
}
/** shrink the bbox in each dimension by the given amount */
void shrink(const float v) {
shrink(Point3(v,v,v));
}
/** shrink the bbox by the amount given for each dimension */
void shrink(const Point3& p) {
p1 += p; // increase minimum
p2 -= p; // decrease maximum
}
/** grow the bbox by the amount given for each dimension */
void grow(const float v) {
grow(Point3(v,v,v));
}
/** grow the bbox by the amount given for each dimension */
void grow(const Point3& p) {
p1 -= p; // decrease minimum
p2 += p; // increase maximum
}
/** set both, min/max z to the same value */
void setZ(const float z) {
p1.z = z;
p2.z = z;
}
/** does the bbox contain the given point? */
bool contains(const Point3& p) const {
if (p.x < p1.x) {return false;}
if (p.x > p2.x) {return false;}
if (p.y < p1.y) {return false;}
if (p.y > p2.y) {return false;}
if (p.z < p1.z) {return false;}
if (p.z > p2.z) {return false;}
return true;
}
};
#endif // BBOX3_H