10 ///\brief A simple two dimensional vector and a bounding box implementation 
 
    12 /// The class \ref hugo::xy "xy" implements
 
    13 ///a two dimensional vector with the usual
 
    16 /// The class \ref hugo::BoundingBox "BoundingBox" can be used to determine
 
    17 /// the rectangular bounding box a set of \ref hugo::xy "xy"'s.
 
    21 2 dimensional vector (plainvector) implementation
 
    31       ///Default constructor: both coordinates become 0
 
    34       ///Constructing the instance from coordinates
 
    35       xy(T a, T b) : x(a), y(a) { }
 
    38       ///Gives back the square of the norm of the vector
 
    43       ///Increments the left hand side by u
 
    44       xy<T>& operator +=(const xy<T>& u){
 
    50       ///Decrements the left hand side by u
 
    51       xy<T>& operator -=(const xy<T>& u){
 
    57       ///Multiplying the left hand side with a scalar
 
    58       xy<T>& operator *=(const T &u){
 
    64       ///Dividing the left hand side by a scalar
 
    65       xy<T>& operator /=(const T &u){
 
    71       ///Returns the scalar product of two vectors
 
    72       T operator *(const xy<T>& u){
 
    76       ///Returns the sum of two vectors
 
    77       xy<T> operator+(const xy<T> &u) const {
 
    82       ///Returns the difference of two vectors
 
    83       xy<T> operator-(const xy<T> &u) const {
 
    88       ///Returns a vector multiplied by a scalar
 
    89       xy<T> operator*(const T &u) const {
 
    94       ///Returns a vector divided by a scalar
 
    95       xy<T> operator/(const T &u) const {
 
   101       bool operator==(const xy<T> &u){
 
   102 	return (x==u.x) && (y==u.y);
 
   105       ///Testing inequality
 
   106       bool operator!=(xy u){
 
   107 	return  (x!=u.x) || (y!=u.y);
 
   112   ///Reading a plainvector from a stream
 
   115   std::istream& operator>>(std::istream &is, xy<T> &z)
 
   122   ///Outputting a plainvector to a stream
 
   125   std::ostream& operator<<(std::ostream &os, xy<T> z)
 
   127     os << "(" << z.x << ", " << z.y << ")";
 
   133      Implementation of a bounding box of plainvectors.
 
   138       xy<T> bottom_left, top_right;
 
   142       ///Default constructor: an empty bounding box
 
   143       BoundingBox() { _empty = true; }
 
   145       ///Constructing the instance from one point
 
   146       BoundingBox(xy<T> a) { bottom_left=top_right=a; _empty = false; }
 
   148       ///Is there any point added
 
   153       ///Gives back the bottom left corner (if the bounding box is empty, then the return value is not defined) 
 
   154       xy<T> bottomLeft() const {
 
   158       ///Gives back the top right corner (if the bounding box is empty, then the return value is not defined) 
 
   159       xy<T> topRight() const {
 
   163       ///Checks whether a point is inside a bounding box
 
   164       bool inside(const xy<T>& u){
 
   168 	  return ((u.x-bottom_left.x)*(top_right.x-u.x) >= 0 &&
 
   169 		  (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 );
 
   173       ///Increments a bounding box with a point
 
   174       BoundingBox& operator +=(const xy<T>& u){
 
   176 	  bottom_left=top_right=u;
 
   180 	  if (bottom_left.x > u.x) bottom_left.x = u.x;
 
   181 	  if (bottom_left.y > u.y) bottom_left.y = u.y;
 
   182 	  if (top_right.x < u.x) top_right.x = u.x;
 
   183 	  if (top_right.y < u.y) top_right.y = u.y;
 
   188       ///Sums a bounding box and a point
 
   189       BoundingBox operator +(const xy<T>& u){
 
   190 	BoundingBox b = *this;
 
   194       ///Increments a bounding box with an other bounding box
 
   195       BoundingBox& operator +=(const BoundingBox &u){
 
   197 	  *this += u.bottomLeft();
 
   198 	  *this += u.topRight();
 
   203       ///Sums two bounding boxes
 
   204       BoundingBox operator +(const BoundingBox& u){
 
   205 	BoundingBox b = *this;
 
   209     };//class Boundingbox