Line. More...
#include <rline.h>
Public Member Functions | |
RLine (void) | |
RLine (const RLine &line) | |
RLine (tCoord x1, tCoord y1, tCoord x2, tCoord y2, bool seg=true, bool reorder=true) | |
RLine (const RPoint &pt1, const RPoint &pt2, bool seg=true, bool reorder=true) | |
int | Compare (const RLine &line) const |
tCoord | GetLength (void) const |
tCoord | GetAngle (bool ccw=true) const |
tCoord | GetAngle (const RLine &line, bool ccw=true) const |
void | SetPoints (tCoord x1, tCoord y1, tCoord x2, tCoord y2, bool seg=true, bool reorder=true) |
void | SetPoints (const RPoint &pt1, const RPoint &pt2, bool seg=true, bool reorder=true) |
bool | IsOrientedTop (void) const |
bool | IsOrientedRight (void) const |
bool | Inter (const RLine &line, RPoint &pt) const |
bool | Inter (const RLine &line) const |
bool | IsIn (const RPoint &pt) const |
tCoord | GetX1 (void) const |
tCoord | GetY1 (void) const |
tCoord | GetX2 (void) const |
tCoord | GetY2 (void) const |
RPoint | GetPt1 (void) const |
RPoint | GetPt2 (void) const |
bool | IsSegment (void) const |
bool | IsHorizontal (void) const |
bool | IsVertical (void) const |
Private Member Functions | |
void | ReOrder (void) |
int | CounterClockwise (const RPoint &pt) const |
Private Attributes | |
RPoint | Pt1 |
RPoint | Pt2 |
bool | Segment |
bool | OrientedTop |
bool | OrientedRight |
Detailed Description
Line.
This class represent a line. Be default, Pt1 is always the most bottom/left point and Pt2 is always the most upper/right point.
A line can also be considered as an oriented segment.
Constructor & Destructor Documentation
RLine | ( | void | ) |
Construct a imaginary line.
Construct a line. The points are eventually exchanged to ensure that the first one is the most left-upper point.
- Parameters
-
x1 X-coordinate of the first point used. y1 Y-coordinate of the first point used. x2 X-coordinate of the second point used. y2 Y-coordinate of the second point used. seg Is the line a segment. reorder Define if the line must be reorder.
Construct a line. The points are eventually exchanged to ensure that the first one is the most left-upper point.
- Parameters
-
pt1 The first point used. pt2 The second point used. seg Is the line a segment. reorder Define if the line must be reorder.
Member Function Documentation
|
private |
ReOrder de points if necessary to follow the convention.
int Compare | ( | const RLine & | line | ) | const |
Compare two lines. This function is used with the class RContainer.
- Parameters
-
line Line used for the comparison.
- Returns
- -1 The left-bottom point of the current line is more at the left (at the bottom) of the other one. If identical, the second points are compared.
- 0 if there have the points.
- +1 The left-bottom point of the current line is more at the right ( upper) of the other one. If identical, the second points are compared.
tCoord GetLength | ( | void | ) | const |
Compute the length of the segment formed by both points.
- Returns
- the length.
tCoord GetAngle | ( | bool | ccw = true | ) | const |
Compute the angle of the line compared to an horizontal one.
- Parameters
-
ccw Define if the angles are measured counter-clockwise or not.
- Returns
- the angle.
Compute the angle of the line compared to another one.
- Parameters
-
line Line to compared with. ccw Define if the angles are measured counter-clockwise or not.
- Returns
- the angle.
Set new points to the line.
- Parameters
-
x1 X-coordinate of the first point used. y1 Y-coordinate of the first point used. x2 X-coordinate of the second point used. y2 Y-coordinate of the second point used. seg Is the line a segment. reorder Define if the line must be reorder.
Set new points to the line.
- Parameters
-
pt1 The first point used. pt2 The second point used. seg Is the line a segment. reorder Define if the line must be reorder.
bool IsOrientedTop | ( | void | ) | const |
Look a segment is oriented to the top.
- Returns
- true if it is the case.
- Exceptions
-
An exception is generated if the line is not a segment.
bool IsOrientedRight | ( | void | ) | const |
Look a segment is oriented to the right.
- Returns
- true if it is the case.
- Exceptions
-
An exception is generated if the line is not a segment.
|
private |
Look at the needed clock direction to go between the two extremities by passing by an intermediate point.
- Parameters
-
pt Intermediate point.
- Returns
- -1 if the direction is anticlockwise. 0 if the point is one the two extremities. +1 if the direction is clockwise.
Determine if there is an intersection between two lines. If the two lines are similar, the intersection point is left undefined.
- Parameters
-
line Line used for the comparison. pt Point that will contain the intersection point (if any).
- Returns
- true if there is at least one intersection.
bool Inter | ( | const RLine & | line | ) | const |
Determine if there is an intersection between two lines (To verify!!!).
- Parameters
-
line Line used for the comparison.
- Returns
- true if there is an intersection.
bool IsIn | ( | const RPoint & | pt | ) | const |
Determine if a point is on the line/segment.
- Parameters
-
pt Point used for the comparison.
- Returns
- true if there the point is contained.
tCoord GetX1 | ( | void | ) | const |
Get the X position of the first point.
- Returns
- a coordinate.
tCoord GetY1 | ( | void | ) | const |
Get the Y position of the first point.
- Returns
- a coordinate.
tCoord GetX2 | ( | void | ) | const |
Get the X position of the second point.
- Returns
- a coordinate.
tCoord GetY2 | ( | void | ) | const |
Get the Y position of the second point.
- Returns
- a coordinate.
RPoint GetPt1 | ( | void | ) | const |
Get the most left-bottom point.
- Returns
- a point.
RPoint GetPt2 | ( | void | ) | const |
Get the most right-up point.
- Returns
- a point.
bool IsSegment | ( | void | ) | const |
Verify that if the line is a segment or not.
- Returns
- true if it is a segment.
bool IsHorizontal | ( | void | ) | const |
Verify if a line is a horizontal one.
- Returns
- true if the line is horizontal.
bool IsVertical | ( | void | ) | const |
Verify if a line is a vertical one.
- Returns
- true if the line is vertical.
Field Documentation
|
private |
The First point of the line.
|
private |
The second point of the line.
|
private |
Is the line a segment delimited by the two points.
|
private |
Is the segment oriented to the top.
|
private |
Is the segment oriented to the right.