Point2D< coord_type > Class Template Reference

#include <points.h>


Detailed Description

template<class coord_type>
class Point2D< coord_type >

Definition at line 37 of file points.h.


Public Member Functions

coord_type getX () const
coord_type getY () const
double magnitude () const
template<class point_type>
bool operator!= (const Point2D< point_type > &old) const
template<class point_type>
Point2D< coord_type > & operator+= (const Point2D< point_type > &old)
template<class point_type>
Point2D< coord_type > & operator-= (const Point2D< point_type > &old)
Point2D< coord_type > & operator= (const Point2D< coord_type > &old)
template<class point_type>
Point2D< coord_type > & operator= (const Point2D< point_type > &old)
template<class point_type>
bool operator== (const Point2D< point_type > &old) const
coord_type operator[] (int i) const
 Point2D (const Point2D< coord_type > &old)
template<class point_type>
 Point2D (const Point2D< point_type > &old)
 Point2D (coord_type x0, coord_type y0)
 Point2D ()
void rotate (double angle)
void set (coord_type nx, coord_type ny)
void setX (coord_type nx)
void setY (coord_type ny)
void swap ()
coord_type x () const
coord_type y () const
 ~Point2D ()

Protected Attributes

coord_type _x
coord_type _y

Constructor & Destructor Documentation

template<class coord_type>
Point2D< coord_type >::Point2D (  )  [inline]

Definition at line 42 of file points.h.

00043           {
00044             _x=_y=-1;
00045            }

template<class coord_type>
Point2D< coord_type >::Point2D ( coord_type  x0,
coord_type  y0 
) [inline]

Definition at line 47 of file points.h.

00048                   {
00049                     _x  = x0;
00050                     _y  = y0;
00051                    }

template<class coord_type>
template<class point_type>
Point2D< coord_type >::Point2D ( const Point2D< point_type > &  old  )  [inline]

template<class coord_type>
Point2D< coord_type >::Point2D ( const Point2D< coord_type > &  old  )  [inline]

template<class coord_type>
Point2D< coord_type >::~Point2D (  )  [inline]

Definition at line 90 of file points.h.

00091           {
00092            }


Member Function Documentation

template<class coord_type>
coord_type Point2D< coord_type >::getX (  )  const [inline]

template<class coord_type>
coord_type Point2D< coord_type >::getY (  )  const [inline]

template<class coord_type>
double Point2D< coord_type >::magnitude (  )  const [inline]

Definition at line 170 of file points.h.

00171           {
00172             return (sqrt(_x*_x+_y*_y));
00173            }

template<class coord_type>
template<class point_type>
bool Point2D< coord_type >::operator!= ( const Point2D< point_type > &  old  )  const [inline]

Definition at line 123 of file points.h.

00124                   {
00125                     if ((_x == old._x)&&(_y==old._y))
00126                         return false;
00127                     else
00128                         return true;
00129                    }

template<class coord_type>
template<class point_type>
Point2D<coord_type>& Point2D< coord_type >::operator+= ( const Point2D< point_type > &  old  )  [inline]

Definition at line 133 of file points.h.

00134                   {
00135                     _x += old._x;
00136                     _y += old._y;
00137 
00138                     return *this;
00139                    }

template<class coord_type>
template<class point_type>
Point2D<coord_type>& Point2D< coord_type >::operator-= ( const Point2D< point_type > &  old  )  [inline]

Definition at line 142 of file points.h.

00143                   {
00144                     _x -= old._x;
00145                     _y -= old._y;
00146 
00147                     return *this;
00148                    }

template<class coord_type>
Point2D<coord_type>& Point2D< coord_type >::operator= ( const Point2D< coord_type > &  old  )  [inline]

Definition at line 83 of file points.h.

00084           {
00085             _x = old._x;
00086             _y = old._y;
00087             return *this;
00088            }

template<class coord_type>
template<class point_type>
Point2D<coord_type>& Point2D< coord_type >::operator= ( const Point2D< point_type > &  old  )  [inline]

Definition at line 61 of file points.h.

00062                   {
00063                     _x  = old.getX();
00064                     _y  = old.getY();
00065 
00066                     return *this;
00067                    }

template<class coord_type>
template<class point_type>
bool Point2D< coord_type >::operator== ( const Point2D< point_type > &  old  )  const [inline]

Definition at line 114 of file points.h.

00115                   {
00116                     if ((_x == old._x)&&(_y==old._y))
00117                         return true;
00118                     else
00119                         return false;
00120                    }

template<class coord_type>
coord_type Point2D< coord_type >::operator[] ( int  i  )  const [inline]

Definition at line 103 of file points.h.

00103                                            {
00104           switch(i) {
00105             case 0: return _x;
00106             case 1: return _y;
00107             case 2: return 1;
00108             default: assert(NULL == "Point2D::operator[] index out of range");
00109                      return 0;
00110           }
00111         }

template<class coord_type>
void Point2D< coord_type >::rotate ( double  angle  )  [inline]

NOTE: The angle is assumed to be in RADIANS.

Definition at line 153 of file points.h.

00154           {
00155             coord_type rot_x=0;
00156             coord_type rot_y=0;
00157 
00158             rot_x  = ( _x*cos(angle)+_y*sin(angle));
00159             rot_y  = (-_x*sin(angle)+_y*cos(angle));
00160 
00161             _x = rot_x;
00162             _y = rot_y;
00163            }

template<class coord_type>
void Point2D< coord_type >::set ( coord_type  nx,
coord_type  ny 
) [inline]

Definition at line 101 of file points.h.

00101 { setX(nx); setY(ny); }

template<class coord_type>
void Point2D< coord_type >::setX ( coord_type  nx  )  [inline]

template<class coord_type>
void Point2D< coord_type >::setY ( coord_type  ny  )  [inline]

template<class coord_type>
void Point2D< coord_type >::swap (  )  [inline]

Definition at line 165 of file points.h.

00166           {
00167             std::swap(_x,_y);
00168            }

template<class coord_type>
coord_type Point2D< coord_type >::x (  )  const [inline]

template<class coord_type>
coord_type Point2D< coord_type >::y (  )  const [inline]


Field Documentation

template<class coord_type>
coord_type Point2D< coord_type >::_x [protected]

template<class coord_type>
coord_type Point2D< coord_type >::_y [protected]


The documentation for this class was generated from the following file:

Generated on Wed May 5 00:06:58 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6