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

Coord Class Reference

#include <Coord.h>

List of all members.


Detailed Description

Class for storing host positions.

Class for a double-tuple storing a position / two-dimensional vector. Some comparison and basic arithmetic operators on Coord structures are implemented.

Author:
Christian Frank


Public Member Functions

 Coord (double _x=0, double _y=0)
 Coord (const Coord &pos)
 Coord (const Coord *pos)
std::string info () const
Coord operator+= (Coord a)
Coord operator= (Coord a)
Coord operator-= (Coord a)
double distance (const Coord a) const
double sqrdist (const Coord a) const

Public Attributes

double x
 x and y coordinates of the position
double y
 x and y coordinates of the position

Friends

Coord operator+ (Coord a, Coord b)
Coord operator- (Coord a, Coord b)
Coord operator * (Coord a, double f)
Coord operator/ (Coord a, double f)
bool operator== (Coord a, Coord b)
bool operator!= (Coord a, Coord b)


Constructor & Destructor Documentation

Coord::Coord double  _x = 0,
double  _y = 0
[inline]
 

Initializes coordinates.

00045 : x(_x), y(_y) {};

Coord::Coord const Coord pos  )  [inline]
 

Initializes coordinates.

00049                             {
00050         x=pos.x;
00051         y=pos.y;
00052   }

Coord::Coord const Coord pos  )  [inline]
 

Initializes coordinates.

00055                             {
00056         x=pos->x;
00057         y=pos->y;
00058   }


Member Function Documentation

double Coord::distance const Coord  a  )  const [inline]
 

Returns the distance to Coord a

00127                                          {
00128     Coord dist=*this-a;
00129     return sqrt( dist.x*dist.x + dist.y*dist.y);
00130   }

std::string Coord::info  )  const [inline]
 

00060                          {
00061         std::stringstream os;
00062         os << "(" << x << "," << y << ")";
00063         return os.str();
00064   }

Coord Coord::operator+= Coord  a  )  [inline]
 

Adds coordinate vector b to a.

00087                             {
00088     x+=a.x;
00089     y+=a.y;
00090     return *this;
00091   }

Coord Coord::operator-= Coord  a  )  [inline]
 

Subtracts coordinate vector b from a.

00101                             {
00102     x-=a.x;
00103     y-=a.y;
00104     return *this;
00105   }

Coord Coord::operator= Coord  a  )  [inline]
 

Assigns a this.

00094                            {
00095     x=a.x;
00096     y=a.y;
00097     return *this;
00098   }

double Coord::sqrdist const Coord  a  )  const [inline]
 

Returns distance^2 to Coord a (omits square root).

00135                                         {
00136     Coord dist=*this-a;
00137     return dist.x*dist.x + dist.y*dist.y;
00138   }


Friends And Related Function Documentation

Coord operator * Coord  a,
double  f
[friend]
 

Multiplies a coordinate vector by a real number.

00077                                             {
00078         return Coord(a.x*f, a.y*f);
00079   }

bool operator!= Coord  a,
Coord  b
[friend]
 

Tests whether two coordinate vectors are not equal. Negation of the operator==.

00120                                            {
00121         return !(a==b);
00122   }

Coord operator+ Coord  a,
Coord  b
[friend]
 

Adds two coordinate vectors.

00067                                            {
00068         return Coord(a.x+b.x, a.y+b.y);
00069   }

Coord operator- Coord  a,
Coord  b
[friend]
 

Subtracts two coordinate vectors.

00072                                            {
00073         return Coord(a.x-b.x, a.y-b.y);
00074   }

Coord operator/ Coord  a,
double  f
[friend]
 

Divides a coordinate vector by a real number.

00082                                             {
00083         return Coord(a.x/f, a.y/f);
00084   }

bool operator== Coord  a,
Coord  b
[friend]
 

Tests whether two coordinate vectors are equal. Because coordinates are of type double, this is done through the FWMath::close function.

00112                                            {
00113         return FWMath::close(a.x,b.x) && FWMath::close(a.y,b.y);
00114   }


Member Data Documentation

double Coord::x
 

x and y coordinates of the position

double Coord::y
 

x and y coordinates of the position


The documentation for this class was generated from the following file:
Generated on Sat Apr 1 20:52:21 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.1