Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Tools/Boundary.h

Go to the documentation of this file.

    00001 /**
    00002  * @file Boundary.h
    00003  *
    00004  * This file contains the template class Boundary.
    00005  *
    00006  * @author <A href=mailto:roefer@tzi.de>Thomas Röfer</A>
    00007  */
    00008
    00009 #ifndef __BOUNDARY_H__
    00010 #define __BOUNDARY_H__
    00011
    00012 #include "Tools/Math/Vector2.h"
    00013 #include "Range.h"
    00014
    00015 /**
    00016  * The template class represents rectangular boundaries.
    00017  */
    00018 template<class T> class Boundary
    00019 {
    00020   public:
    00021     Range<T> x, /**< The range in x-direction. */
    00022              y; /**< The range in y-direction. */
    00023
    00024     /**
    00025      * Constructor.
    00026      */
    00027     Boundary() : x(0,0), y(0,0) {}
    00028
    00029     /**
    00030      * Constructor.
    00031      * This constructor allows to specify the minimum and maximum values
    00032      * for type T, e.g. -HUGE_VAL and HUGE_VAL for double. These limits
    00033      * are used to construct the object, so that it can adapt to any boundary later.
    00034      * @param min The minimum value of T.
    00035      * @param max The maximum value of T.
    00036      */
    00037     Boundary(T min,T max)
    00038     : x(max,min), y(max,min) {}
    00039
    00040     /**
    00041      * The function enlarges the boundary so that it also includes the specified point.
    00042      * @param p The point.
    00043      */
    00044     void add(const Vector2<T>& p)
    00045     {
    00046       x.add(p.x),
    00047       y.add(p.y);
    00048     }
    00049
    00050     /**
    00051      * The function enlarges the boundary so that it also includes another boundary.
    00052      * @param b The other boundary.
    00053      */
    00054     void add(const Boundary<T>& b)     // add function for adding Boundaries
    00055     {
    00056       x.add(b.x);
    00057       y.add(b.y);
    00058     }
    00059
    00060     /**
    00061      * The function checks whether a certain point is enclosed by the boundary
    00062      * @param p The point.
    00063      * @return Lies the point inside the boundary?
    00064      */
    00065     bool isInside(const Vector2<T>& p) const
    00066       {return x.isInside(p.x) && y.isInside(p.y);}
    00067 };
    00068
    00069 #endif // __BOUNDARY_H_