INET Framework for OMNeT++/OMNEST
Coord Class Reference

Class for storing host positions. More...

#include <Coord.h>

List of all members.

Public Member Functions

 Coord (double _x=0, double _y=0)
 Coord (const Coord &pos)
 Coord (const Coord *pos)
std::string info () const
const Coordoperator+= (const Coord &a)
const Coordoperator= (const Coord &a)
const Coordoperator-= (const 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

Friends

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

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

Constructor & Destructor Documentation

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

Initializes coordinates.

: x(_x), y(_y) {};
Coord::Coord ( const Coord pos) [inline]

Initializes coordinates.

                          {
        x=pos.x;
        y=pos.y;
  }
Coord::Coord ( const Coord pos) [inline]

Initializes coordinates.

                          {
        x=pos->x;
        y=pos->y;
  }

Member Function Documentation

std::string Coord::info ( ) const [inline]
                         {
        std::stringstream os;
        os << "(" << x << "," << y << ")";
        return os.str();
  }
const Coord& Coord::operator+= ( const Coord a) [inline]

Adds coordinate vector b to a.

                                          {
        x+=a.x;
        y+=a.y;
        return *this;
  }
const Coord& Coord::operator-= ( const Coord a) [inline]

Subtracts coordinate vector b from a.

                                          {
        x-=a.x;
        y-=a.y;
        return *this;
  }
const Coord& Coord::operator= ( const Coord a) [inline]

Assigns a this.

                                         {
        x=a.x;
        y=a.y;
        return *this;
  }
double Coord::sqrdist ( const Coord a) const [inline]

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

Referenced by ChannelControl::updateConnections().

                                       {
        double dx=x-a.x;
        double dy=y-a.y;
        return dx*dx + dy*dy;
  }

Friends And Related Function Documentation

bool operator!= ( const Coord a,
const Coord b 
) [friend]

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

                                                         {
        return !(a==b);
  }
Coord operator* ( const Coord a,
double  f 
) [friend]

Multiplies a coordinate vector by a real number.

                                                   {
        return Coord(a.x*f, a.y*f);
  }
Coord operator+ ( const Coord a,
const Coord b 
) [friend]

Adds two coordinate vectors.

                                                         {
        return Coord(a.x+b.x, a.y+b.y);
  }
Coord operator- ( const Coord a,
const Coord b 
) [friend]

Subtracts two coordinate vectors.

                                                         {
        return Coord(a.x-b.x, a.y-b.y);
  }
Coord operator/ ( const Coord a,
double  f 
) [friend]

Divides a coordinate vector by a real number.

                                                   {
        return Coord(a.x/f, a.y/f);
  }
bool operator== ( const Coord a,
const Coord b 
) [friend]

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

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

Member Data Documentation


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