43 : myXmin(10000000000.0), myXmax(-10000000000.0),
44 myYmin(10000000000.0), myYmax(-10000000000.0),
45 myZmin(10000000000.0), myZmax(-10000000000.0),
46 myWasInitialised(false) {}
224 const double leftDist =
myXmin - p.
x();
225 const double rightDist = p.
x() -
myXmax;
226 const double bottomDist =
myYmin - p.
y();
227 const double topDist = p.
y() -
myYmax;
229 if (bottomDist > 0.) {
230 return sqrt(leftDist * leftDist + bottomDist * bottomDist);
233 return sqrt(leftDist * leftDist + topDist * topDist);
237 if (rightDist > 0.) {
238 if (bottomDist > 0.) {
239 return sqrt(rightDist * rightDist + bottomDist * bottomDist);
242 return sqrt(rightDist * rightDist + topDist * topDist);
246 if (bottomDist > 0) {
263 if (bottomDist > 0.) {
264 return sqrt(leftDist * leftDist + bottomDist * bottomDist);
267 return sqrt(leftDist * leftDist + topDist * topDist);
271 if (rightDist > 0.) {
272 if (bottomDist > 0.) {
273 return sqrt(rightDist * rightDist + bottomDist * bottomDist);
276 return sqrt(rightDist * rightDist + topDist * topDist);
280 if (bottomDist > 0) {
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
virtual bool partialWithin(const AbstractPoly &poly, double offset=0) const =0
double ymin() const
Returns minimum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
double z() const
Returns the z-position.
double y() const
Returns the y-position.
bool crosses(const Position &p1, const Position &p2) const
Returns whether the boundary crosses the given line.
void moveby(double x, double y, double z=0)
Moves the boundary by the given amount.
double x() const
Returns the x-position.
virtual bool crosses(const Position &p1, const Position &p2) const =0
void set(double xmin, double ymin, double xmax, double ymax)
Sets the boundary to the given values.
double zmax() const
Returns maximum z-coordinate.
double getWidth() const
Returns the width of the boudary (x-axis)
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
friend std::ostream & operator<<(std::ostream &os, const Boundary &b)
Output operator.
double zmin() const
Returns minimum z-coordinate.
A class that stores a 2D geometrical boundary.
double myXmin
The boundaries.
A point in 2D or 3D with translation and scaling methods.
virtual bool around(const Position &p, double offset=0) const =0
double xmin() const
Returns minimum x-coordinate.
bool myWasInitialised
Information whether the boundary was initialised.
Boundary & grow(double by)
extends the boundary by the given amount
void growHeight(double by)
Increases the height of the boundary (y-axis)
void reset()
Resets the boundary.
bool partialWithin(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary is partially within the given polygon.
double getHeight() const
Returns the height of the boundary (y-axis)
void flipY()
flips ymin and ymax
bool around(const Position &p, double offset=0) const
Returns whether the boundary contains the given coordinate.
void growWidth(double by)
Increases the width of the boundary (x-axis)
Position getCenter() const
Returns the center of the boundary.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
double ymax() const
Returns maximum y-coordinate.
double getZRange() const
Returns the elevation range of the boundary (z-axis)
Boundary()
Constructor - the boundary is unset.
bool intersects(const Position &p1, const Position &p2) const
Returns the information whether this list of points interesects the given line.