xy.h went to src/include.
authoralpar
Mon, 26 Apr 2004 18:22:34 +0000
changeset 432a51ba0e51a3a
parent 431 79a5641f2dbc
child 433 d9fac1497298
xy.h went to src/include.
doc/Doxyfile
src/include/xy.h
src/work/athos/xy/xy.h
     1.1 --- a/doc/Doxyfile	Mon Apr 26 18:16:42 2004 +0000
     1.2 +++ b/doc/Doxyfile	Mon Apr 26 18:22:34 2004 +0000
     1.3 @@ -401,8 +401,8 @@
     1.4                           ../src/include/fib_heap.h \
     1.5                           ../src/include/dimacs.h \
     1.6  			 ../src/include/time_measure.h \
     1.7 +                         ../src/include/xy.h \
     1.8                           ../src/work/alpar/list_graph.h \
     1.9 -                         ../src/work/athos/xy/xy.h \
    1.10                           ../src/work/athos/minlengthpaths.h \
    1.11  			 ../src/work/marci/graph_wrapper.h	
    1.12                           
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/include/xy.h	Mon Apr 26 18:22:34 2004 +0000
     2.3 @@ -0,0 +1,221 @@
     2.4 +// -*- c++ -*-
     2.5 +#ifndef HUGO_XY_H
     2.6 +#define HUGO_XY_H
     2.7 +
     2.8 +#include <iostream>
     2.9 +
    2.10 +///ingroup misc
    2.11 +///\file
    2.12 +///\brief A simple two dimensional vector and a bounding box implementation 
    2.13 +///
    2.14 +/// The class \ref hugo::xy "xy" implements
    2.15 +///a two dimensional vector with the usual
    2.16 +/// operations.
    2.17 +///
    2.18 +/// The class \ref hugo::BoundingBox "BoundingBox" can be used to determine
    2.19 +/// the rectangular bounding box a set of \ref hugo::xy "xy"'s.
    2.20 +
    2.21 +
    2.22 +namespace hugo {
    2.23 +
    2.24 +  /// \addtogroup misc
    2.25 +  /// @{
    2.26 +
    2.27 +/** \brief
    2.28 +2 dimensional vector (plainvector) implementation
    2.29 +
    2.30 +*/
    2.31 +  template<typename T>
    2.32 +    class xy {
    2.33 +
    2.34 +    public:
    2.35 +
    2.36 +      T x,y;     
    2.37 +      
    2.38 +      ///Default constructor: both coordinates become 0
    2.39 +      xy() : x(0), y(0) {}
    2.40 +
    2.41 +      ///Constructing the instance from coordinates
    2.42 +      xy(T a, T b) : x(a), y(a) { }
    2.43 +
    2.44 +
    2.45 +      ///Gives back the square of the norm of the vector
    2.46 +      T normSquare(){
    2.47 +	return x*x+y*y;
    2.48 +      };
    2.49 +  
    2.50 +      ///Increments the left hand side by u
    2.51 +      xy<T>& operator +=(const xy<T>& u){
    2.52 +	x += u.x;
    2.53 +	y += u.y;
    2.54 +	return *this;
    2.55 +      };
    2.56 +  
    2.57 +      ///Decrements the left hand side by u
    2.58 +      xy<T>& operator -=(const xy<T>& u){
    2.59 +	x -= u.x;
    2.60 +	y -= u.y;
    2.61 +	return *this;
    2.62 +      };
    2.63 +
    2.64 +      ///Multiplying the left hand side with a scalar
    2.65 +      xy<T>& operator *=(const T &u){
    2.66 +	x *= u;
    2.67 +	y *= u;
    2.68 +	return *this;
    2.69 +      };
    2.70 +
    2.71 +      ///Dividing the left hand side by a scalar
    2.72 +      xy<T>& operator /=(const T &u){
    2.73 +	x /= u;
    2.74 +	y /= u;
    2.75 +	return *this;
    2.76 +      };
    2.77 +  
    2.78 +      ///Returns the scalar product of two vectors
    2.79 +      T operator *(const xy<T>& u){
    2.80 +	return x*u.x+y*u.y;
    2.81 +      };
    2.82 +  
    2.83 +      ///Returns the sum of two vectors
    2.84 +      xy<T> operator+(const xy<T> &u) const {
    2.85 +	xy<T> b=*this;
    2.86 +	return b+=u;
    2.87 +      };
    2.88 +
    2.89 +      ///Returns the difference of two vectors
    2.90 +      xy<T> operator-(const xy<T> &u) const {
    2.91 +	xy<T> b=*this;
    2.92 +	return b-=u;
    2.93 +      };
    2.94 +
    2.95 +      ///Returns a vector multiplied by a scalar
    2.96 +      xy<T> operator*(const T &u) const {
    2.97 +	xy<T> b=*this;
    2.98 +	return b*=u;
    2.99 +      };
   2.100 +
   2.101 +      ///Returns a vector divided by a scalar
   2.102 +      xy<T> operator/(const T &u) const {
   2.103 +	xy<T> b=*this;
   2.104 +	return b/=u;
   2.105 +      };
   2.106 +
   2.107 +      ///Testing equality
   2.108 +      bool operator==(const xy<T> &u){
   2.109 +	return (x==u.x) && (y==u.y);
   2.110 +      };
   2.111 +
   2.112 +      ///Testing inequality
   2.113 +      bool operator!=(xy u){
   2.114 +	return  (x!=u.x) || (y!=u.y);
   2.115 +      };
   2.116 +
   2.117 +    };
   2.118 +
   2.119 +  ///Reading a plainvector from a stream
   2.120 +  template<typename T>
   2.121 +  inline
   2.122 +  std::istream& operator>>(std::istream &is, xy<T> &z)
   2.123 +  {
   2.124 +
   2.125 +    is >> z.x >> z.y;
   2.126 +    return is;
   2.127 +  }
   2.128 +
   2.129 +  ///Outputting a plainvector to a stream
   2.130 +  template<typename T>
   2.131 +  inline
   2.132 +  std::ostream& operator<<(std::ostream &os, xy<T> z)
   2.133 +  {
   2.134 +    os << "(" << z.x << ", " << z.y << ")";
   2.135 +    return os;
   2.136 +  }
   2.137 +
   2.138 +
   2.139 +  /** \brief
   2.140 +     Implementation of a bounding box of plainvectors.
   2.141 +     
   2.142 +  */
   2.143 +  template<typename T>
   2.144 +    class BoundingBox {
   2.145 +      xy<T> bottom_left, top_right;
   2.146 +      bool _empty;
   2.147 +    public:
   2.148 +      
   2.149 +      ///Default constructor: an empty bounding box
   2.150 +      BoundingBox() { _empty = true; }
   2.151 +
   2.152 +      ///Constructing the instance from one point
   2.153 +      BoundingBox(xy<T> a) { bottom_left=top_right=a; _empty = false; }
   2.154 +
   2.155 +      ///Is there any point added
   2.156 +      bool empty() const {
   2.157 +	return _empty;
   2.158 +      }
   2.159 +
   2.160 +      ///Gives back the bottom left corner (if the bounding box is empty, then the return value is not defined) 
   2.161 +      xy<T> bottomLeft() const {
   2.162 +	return bottom_left;
   2.163 +      };
   2.164 +
   2.165 +      ///Gives back the top right corner (if the bounding box is empty, then the return value is not defined) 
   2.166 +      xy<T> topRight() const {
   2.167 +	return top_right;
   2.168 +      };
   2.169 +
   2.170 +      ///Checks whether a point is inside a bounding box
   2.171 +      bool inside(const xy<T>& u){
   2.172 +	if (_empty)
   2.173 +	  return false;
   2.174 +	else{
   2.175 +	  return ((u.x-bottom_left.x)*(top_right.x-u.x) >= 0 &&
   2.176 +		  (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 );
   2.177 +	}
   2.178 +      }
   2.179 +  
   2.180 +      ///Increments a bounding box with a point
   2.181 +      BoundingBox& operator +=(const xy<T>& u){
   2.182 +	if (_empty){
   2.183 +	  bottom_left=top_right=u;
   2.184 +	  _empty = false;
   2.185 +	}
   2.186 +	else{
   2.187 +	  if (bottom_left.x > u.x) bottom_left.x = u.x;
   2.188 +	  if (bottom_left.y > u.y) bottom_left.y = u.y;
   2.189 +	  if (top_right.x < u.x) top_right.x = u.x;
   2.190 +	  if (top_right.y < u.y) top_right.y = u.y;
   2.191 +	}
   2.192 +	return *this;
   2.193 +      };
   2.194 +  
   2.195 +      ///Sums a bounding box and a point
   2.196 +      BoundingBox operator +(const xy<T>& u){
   2.197 +	BoundingBox b = *this;
   2.198 +	return b += u;
   2.199 +      };
   2.200 +
   2.201 +      ///Increments a bounding box with an other bounding box
   2.202 +      BoundingBox& operator +=(const BoundingBox &u){
   2.203 +	if ( !u.empty() ){
   2.204 +	  *this += u.bottomLeft();
   2.205 +	  *this += u.topRight();
   2.206 +	}
   2.207 +	return *this;
   2.208 +      };
   2.209 +  
   2.210 +      ///Sums two bounding boxes
   2.211 +      BoundingBox operator +(const BoundingBox& u){
   2.212 +	BoundingBox b = *this;
   2.213 +	return b += u;
   2.214 +      };
   2.215 +
   2.216 +    };//class Boundingbox
   2.217 +
   2.218 +
   2.219 +  /// @}
   2.220 +
   2.221 +
   2.222 +} //namespace hugo
   2.223 +
   2.224 +#endif //HUGO_XY_H
     3.1 --- a/src/work/athos/xy/xy.h	Mon Apr 26 18:16:42 2004 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,221 +0,0 @@
     3.4 -// -*- c++ -*-
     3.5 -#ifndef HUGO_XY_H
     3.6 -#define HUGO_XY_H
     3.7 -
     3.8 -#include <iostream>
     3.9 -
    3.10 -///ingroup misc
    3.11 -///\file
    3.12 -///\brief A simple two dimensional vector and a bounding box implementation 
    3.13 -///
    3.14 -/// The class \ref hugo::xy "xy" implements
    3.15 -///a two dimensional vector with the usual
    3.16 -/// operations.
    3.17 -///
    3.18 -/// The class \ref hugo::BoundingBox "BoundingBox" can be used to determine
    3.19 -/// the rectangular bounding box a set of \ref hugo::xy "xy"'s.
    3.20 -
    3.21 -
    3.22 -namespace hugo {
    3.23 -
    3.24 -  /// \addtogroup misc
    3.25 -  /// @{
    3.26 -
    3.27 -/** \brief
    3.28 -2 dimensional vector (plainvector) implementation
    3.29 -
    3.30 -*/
    3.31 -  template<typename T>
    3.32 -    class xy {
    3.33 -
    3.34 -    public:
    3.35 -
    3.36 -      T x,y;     
    3.37 -      
    3.38 -      ///Default constructor: both coordinates become 0
    3.39 -      xy() : x(0), y(0) {}
    3.40 -
    3.41 -      ///Constructing the instance from coordinates
    3.42 -      xy(T a, T b) : x(a), y(a) { }
    3.43 -
    3.44 -
    3.45 -      ///Gives back the square of the norm of the vector
    3.46 -      T normSquare(){
    3.47 -	return x*x+y*y;
    3.48 -      };
    3.49 -  
    3.50 -      ///Increments the left hand side by u
    3.51 -      xy<T>& operator +=(const xy<T>& u){
    3.52 -	x += u.x;
    3.53 -	y += u.y;
    3.54 -	return *this;
    3.55 -      };
    3.56 -  
    3.57 -      ///Decrements the left hand side by u
    3.58 -      xy<T>& operator -=(const xy<T>& u){
    3.59 -	x -= u.x;
    3.60 -	y -= u.y;
    3.61 -	return *this;
    3.62 -      };
    3.63 -
    3.64 -      ///Multiplying the left hand side with a scalar
    3.65 -      xy<T>& operator *=(const T &u){
    3.66 -	x *= u;
    3.67 -	y *= u;
    3.68 -	return *this;
    3.69 -      };
    3.70 -
    3.71 -      ///Dividing the left hand side by a scalar
    3.72 -      xy<T>& operator /=(const T &u){
    3.73 -	x /= u;
    3.74 -	y /= u;
    3.75 -	return *this;
    3.76 -      };
    3.77 -  
    3.78 -      ///Returns the scalar product of two vectors
    3.79 -      T operator *(const xy<T>& u){
    3.80 -	return x*u.x+y*u.y;
    3.81 -      };
    3.82 -  
    3.83 -      ///Returns the sum of two vectors
    3.84 -      xy<T> operator+(const xy<T> &u) const {
    3.85 -	xy<T> b=*this;
    3.86 -	return b+=u;
    3.87 -      };
    3.88 -
    3.89 -      ///Returns the difference of two vectors
    3.90 -      xy<T> operator-(const xy<T> &u) const {
    3.91 -	xy<T> b=*this;
    3.92 -	return b-=u;
    3.93 -      };
    3.94 -
    3.95 -      ///Returns a vector multiplied by a scalar
    3.96 -      xy<T> operator*(const T &u) const {
    3.97 -	xy<T> b=*this;
    3.98 -	return b*=u;
    3.99 -      };
   3.100 -
   3.101 -      ///Returns a vector divided by a scalar
   3.102 -      xy<T> operator/(const T &u) const {
   3.103 -	xy<T> b=*this;
   3.104 -	return b/=u;
   3.105 -      };
   3.106 -
   3.107 -      ///Testing equality
   3.108 -      bool operator==(const xy<T> &u){
   3.109 -	return (x==u.x) && (y==u.y);
   3.110 -      };
   3.111 -
   3.112 -      ///Testing inequality
   3.113 -      bool operator!=(xy u){
   3.114 -	return  (x!=u.x) || (y!=u.y);
   3.115 -      };
   3.116 -
   3.117 -    };
   3.118 -
   3.119 -  ///Reading a plainvector from a stream
   3.120 -  template<typename T>
   3.121 -  inline
   3.122 -  std::istream& operator>>(std::istream &is, xy<T> &z)
   3.123 -  {
   3.124 -
   3.125 -    is >> z.x >> z.y;
   3.126 -    return is;
   3.127 -  }
   3.128 -
   3.129 -  ///Outputting a plainvector to a stream
   3.130 -  template<typename T>
   3.131 -  inline
   3.132 -  std::ostream& operator<<(std::ostream &os, xy<T> z)
   3.133 -  {
   3.134 -    os << "(" << z.x << ", " << z.y << ")";
   3.135 -    return os;
   3.136 -  }
   3.137 -
   3.138 -
   3.139 -  /** \brief
   3.140 -     Implementation of a bounding box of plainvectors.
   3.141 -     
   3.142 -  */
   3.143 -  template<typename T>
   3.144 -    class BoundingBox {
   3.145 -      xy<T> bottom_left, top_right;
   3.146 -      bool _empty;
   3.147 -    public:
   3.148 -      
   3.149 -      ///Default constructor: an empty bounding box
   3.150 -      BoundingBox() { _empty = true; }
   3.151 -
   3.152 -      ///Constructing the instance from one point
   3.153 -      BoundingBox(xy<T> a) { bottom_left=top_right=a; _empty = false; }
   3.154 -
   3.155 -      ///Is there any point added
   3.156 -      bool empty() const {
   3.157 -	return _empty;
   3.158 -      }
   3.159 -
   3.160 -      ///Gives back the bottom left corner (if the bounding box is empty, then the return value is not defined) 
   3.161 -      xy<T> bottomLeft() const {
   3.162 -	return bottom_left;
   3.163 -      };
   3.164 -
   3.165 -      ///Gives back the top right corner (if the bounding box is empty, then the return value is not defined) 
   3.166 -      xy<T> topRight() const {
   3.167 -	return top_right;
   3.168 -      };
   3.169 -
   3.170 -      ///Checks whether a point is inside a bounding box
   3.171 -      bool inside(const xy<T>& u){
   3.172 -	if (_empty)
   3.173 -	  return false;
   3.174 -	else{
   3.175 -	  return ((u.x-bottom_left.x)*(top_right.x-u.x) >= 0 &&
   3.176 -		  (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 );
   3.177 -	}
   3.178 -      }
   3.179 -  
   3.180 -      ///Increments a bounding box with a point
   3.181 -      BoundingBox& operator +=(const xy<T>& u){
   3.182 -	if (_empty){
   3.183 -	  bottom_left=top_right=u;
   3.184 -	  _empty = false;
   3.185 -	}
   3.186 -	else{
   3.187 -	  if (bottom_left.x > u.x) bottom_left.x = u.x;
   3.188 -	  if (bottom_left.y > u.y) bottom_left.y = u.y;
   3.189 -	  if (top_right.x < u.x) top_right.x = u.x;
   3.190 -	  if (top_right.y < u.y) top_right.y = u.y;
   3.191 -	}
   3.192 -	return *this;
   3.193 -      };
   3.194 -  
   3.195 -      ///Sums a bounding box and a point
   3.196 -      BoundingBox operator +(const xy<T>& u){
   3.197 -	BoundingBox b = *this;
   3.198 -	return b += u;
   3.199 -      };
   3.200 -
   3.201 -      ///Increments a bounding box with an other bounding box
   3.202 -      BoundingBox& operator +=(const BoundingBox &u){
   3.203 -	if ( !u.empty() ){
   3.204 -	  *this += u.bottomLeft();
   3.205 -	  *this += u.topRight();
   3.206 -	}
   3.207 -	return *this;
   3.208 -      };
   3.209 -  
   3.210 -      ///Sums two bounding boxes
   3.211 -      BoundingBox operator +(const BoundingBox& u){
   3.212 -	BoundingBox b = *this;
   3.213 -	return b += u;
   3.214 -      };
   3.215 -
   3.216 -    };//class Boundingbox
   3.217 -
   3.218 -
   3.219 -  /// @}
   3.220 -
   3.221 -
   3.222 -} //namespace hugo
   3.223 -
   3.224 -#endif //HUGO_XY_H