Point class. More...
#include <rpoint.h>
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 |
RPoint & | operator+= (const RPoint &pt) |
RPoint & | operator-= (const RPoint &pt) |
int | Compare (const RPoint &pt) const |
RPoint & | operator= (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).
Member Function Documentation
bool operator== | ( | const RPoint & | pt | ) | const |
The equal operator.
- Parameters
-
pt Point used for the comparison.
bool operator!= | ( | const RPoint & | pt | ) | const |
The non-equal operator.
- Parameters
-
pt Point used for the comparison.
Make a translation of the point.
- Parameters
-
pt Point used for the comparison.
Make a translation of the point.
- Parameters
-
pt Point used for the comparison.
int Compare | ( | const RPoint & | pt | ) | const |
Compare two points. This function is used with the class RContainer.
- Parameters
-
pt Point 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.
bool Near | ( | const RPoint & | pt | ) | const |
This function returns true if the two points are side by side.
- Parameters
-
pt Reference point.
Set the point to the given position.
- Parameters
-
x X Position. y Y Position.
Return the Manhattan distance from a given point.
- Parameters
-
pt Reference point.
double EuclideanDist | ( | const RPoint & | pt | ) | const |
Return the euclidean distance from a given point.
- Parameters
-
pt Reference 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
-
pt Point 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
-
pt0 First point. pt1 Second point.
- Returns
- the classification
void ChangeOrientation | ( | const tOrientation | o | ) |
Change the "orientation" of the point.
- Parameters
-
o Orientation.
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
-
f File where to save.
Field Documentation
tCoord X |
This is the X coordinate.
tCoord Y |
This is the Y coordinate.
|
static |
Represent an invalid point.