35 : myXmin(10000000000.0), myXmax(-10000000000.0),
36 myYmin(10000000000.0), myYmax(-10000000000.0),
37 myZmin(10000000000.0), myZmax(-10000000000.0),
38 myWasInitialised(false) {}
42 : myXmin(10000000000.0), myXmax(-10000000000.0),
43 myYmin(10000000000.0), myYmax(-10000000000.0),
44 myZmin(10000000000.0), myZmax(-10000000000.0),
45 myWasInitialised(false) {
52 : myXmin(10000000000.0), myXmax(-10000000000.0),
53 myYmin(10000000000.0), myYmax(-10000000000.0),
54 myZmin(10000000000.0), myZmax(-10000000000.0),
55 myWasInitialised(false) {
222 const double leftDist =
myXmin - p.
x();
223 const double rightDist = p.
x() -
myXmax;
224 const double bottomDist =
myYmin - p.
y();
225 const double topDist = p.
y() -
myYmax;
227 if (bottomDist > 0.) {
228 return sqrt(leftDist * leftDist + bottomDist * bottomDist);
231 return sqrt(leftDist * leftDist + topDist * topDist);
235 if (rightDist > 0.) {
236 if (bottomDist > 0.) {
237 return sqrt(rightDist * rightDist + bottomDist * bottomDist);
240 return sqrt(rightDist * rightDist + topDist * topDist);
244 if (bottomDist > 0) {
261 if (bottomDist > 0.) {
262 return sqrt(leftDist * leftDist + bottomDist * bottomDist);
265 return sqrt(leftDist * leftDist + topDist * topDist);
269 if (rightDist > 0.) {
270 if (bottomDist > 0.) {
271 return sqrt(rightDist * rightDist + bottomDist * bottomDist);
274 return sqrt(rightDist * rightDist + topDist * topDist);
278 if (bottomDist > 0) {
362 return !(*
this == b);
std::ostream & operator<<(std::ostream &os, const Boundary &b)
virtual bool partialWithin(const AbstractPoly &poly, double offset=0) const =0
Returns whether the AbstractPoly is partially within the given polygon.
virtual bool crosses(const Position &p1, const Position &p2) const =0
Returns whether the AbstractPoly crosses the given line.
virtual bool around(const Position &p, double offset=0) const =0
Returns whether the AbstractPoly the given coordinate.
A class that stores a 2D geometrical boundary.
Position getCenter() const
Returns the center of the boundary.
bool partialWithin(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary is partially within the given polygon.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
void moveby(double x, double y, double z=0)
Moves the boundary by the given amount.
void growHeight(double by)
Increases the height of the boundary (y-axis)
bool isInitialised() const
check if Boundary is Initialised
double ymin() const
Returns minimum y-coordinate.
void reset()
Resets the boundary.
double xmin() const
Returns minimum x-coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
void flipY()
flips ymin and ymax
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
double getHeight() const
Returns the height of the boundary (y-axis)
bool myWasInitialised
Information whether the boundary was initialised.
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
Boundary()
Constructor - the boundary is unset.
double getWidth() const
Returns the width of the boudary (x-axis)
bool operator!=(const Boundary &b) const
Comparison operator not equal.
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
void set(double xmin, double ymin, double xmax, double ymax)
Sets the boundary to the given values.
Boundary & scale(double by)
scale the boundary by the given amount
double zmin() const
Returns minimum z-coordinate.
void growWidth(double by)
Increases the width of the boundary (x-axis)
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
bool around(const Position &p, double offset=0) const
Returns whether the AbstractPoly the given coordinate.
double ymax() const
Returns maximum y-coordinate.
double myXmin
The boundaries.
double xmax() const
Returns maximum x-coordinate.
double zmax() const
Returns maximum z-coordinate.
double getZRange() const
Returns the elevation range of the boundary (z-axis)
bool operator==(const Boundary &b) const
Comparison operator equal.
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
double z() const
Returns the z-position.
double y() const
Returns the y-position.
bool intersects(const Position &p1, const Position &p2) const
Returns the information whether this list of points interesects the given line.