Point class. More...

#include <rpoint.h>

Collaboration diagram for RPoint:
[legend]

Public Member Functions

 RPoint (void)
 
 RPoint (tCoord x, tCoord y)
 
 RPoint (const RPoint &pt)
 
bool operator== (const RPoint &pt) const
 
bool operator!= (const RPoint &pt) const
 
RPointoperator+= (const RPoint &pt)
 
RPointoperator-= (const RPoint &pt)
 
int Compare (const RPoint &pt) const
 
RPointoperator= (const RPoint &pt)
 
bool Near (const RPoint &pt) const
 
void Set (tCoord x, tCoord y)
 
tCoord ManhattanDist (const RPoint &pt) const
 
double EuclideanDist (const RPoint &pt) const
 
double Length (void) const
 
bool IsValid (void) const
 
tDirection Classify (const RPoint &pt) const
 
tDirection Classify (const RPoint &pt0, const RPoint &pt1) const
 
void ChangeOrientation (const tOrientation o)
 
void Save (RTextFile &f) const
 

Data Fields

tCoord X
 
tCoord Y
 

Static Public Attributes

static RPoint Null
 

Detailed Description

Point class.

This class represent a point.

Constructor & Destructor Documentation

RPoint ( void  )

Construct a point at (0,0).

RPoint ( tCoord  x,
tCoord  y 
)

Construct a point at (x,y).

Parameters
xX Position.
yY Position.
RPoint ( const RPoint pt)

Construct a point from pt.

Parameters
ptThe point used as reference.

Member Function Documentation

bool operator== ( const RPoint pt) const

The equal operator.

Parameters
ptPoint used for the comparison.
bool operator!= ( const RPoint pt) const

The non-equal operator.

Parameters
ptPoint used for the comparison.
RPoint& operator+= ( const RPoint pt)

Make a translation of the point.

Parameters
ptPoint used for the comparison.
RPoint& operator-= ( const RPoint pt)

Make a translation of the point.

Parameters
ptPoint used for the comparison.
int Compare ( const RPoint pt) const

Compare two points. This function is used with the class RContainer.

Parameters
ptPoint used for the comparison.
Returns
  • A negative value if the current point is more left and/or bottom.
  • 0 if there are at the same position.
  • A positive value if the current point is more right and/or up.
RPoint& operator= ( const RPoint pt)

Assignment operator.

Parameters
ptOriginal point.
bool Near ( const RPoint pt) const

This function returns true if the two points are side by side.

Parameters
ptReference point.
void Set ( tCoord  x,
tCoord  y 
)

Set the point to the given position.

Parameters
xX Position.
yY Position.
tCoord ManhattanDist ( const RPoint pt) const

Return the Manhattan distance from a given point.

Parameters
ptReference point.
double EuclideanDist ( const RPoint pt) const

Return the euclidean distance from a given point.

Parameters
ptReference point.
double Length ( void  ) const

Return the length of the vector represented by the current point.

bool IsValid ( void  ) const

Test if the point is a valid one.

tDirection Classify ( const RPoint pt) const

Search for the classification of a point relative to the current point. If the two points are at the same position, dNoDirection is returned.

Parameters
ptPoint for which the orientation must be find.
Returns
the classification.
tDirection Classify ( const RPoint pt0,
const RPoint pt1 
) const

Search for the classification of the current point relative to the segment formed by two points.

Parameters
pt0First point.
pt1Second point.
Returns
the classification
void ChangeOrientation ( const tOrientation  o)

Change the "orientation" of the point.

Parameters
oOrientation.
void Save ( RTextFile f) const

Save the point in a file. The two coordinates are written on the current line and are separated by the text file separator.

Parameters
fFile where to save.

Field Documentation

tCoord X

This is the X coordinate.

tCoord Y

This is the Y coordinate.

RPoint Null
static

Represent an invalid point.