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_
00070 
00071 /*
00072  * Changelog:
00073  * 
00074  * $Log: Boundary.h,v $
00075  * Revision 1.1.1.1  2004/05/22 17:35:49  cvsadm
00076  * created new repository GT2004_WM
00077  *
00078  * Revision 1.2  2003/12/15 11:44:33  juengel
00079  * Parameters for add function changed.
00080  *
00081  * Revision 1.1  2003/10/07 10:13:20  cvsadm
00082  * Created GT2004 (M.J.)
00083  *
00084  * Revision 1.1  2003/09/26 11:40:39  juengel
00085  * - sorted tools
00086  * - clean-up in DataTypes
00087  *
00088  * Revision 1.1.1.1  2003/07/02 09:40:22  cvsadm
00089  * created new repository for the competitions in Padova from the 
00090  * tamara CVS (Tuesday 2:00 pm)
00091  *
00092  * removed unused solutions
00093  *
00094  * Revision 1.5  2002/12/16 14:53:53  dueffert
00095  * changelog added
00096  *
00097  */

Generated on Thu Sep 23 19:57:37 2004 for GT2004 by doxygen 1.3.6