Aimsun Next Scripting
22
|
Public Member Functions | |
GKLine () | |
GKLine (const GKPoint &p1, const GKPoint &p2) | |
GKLine (const GKPoint &p1, GKCoord slope) | |
GKLine (const GKPoint &p, const GKVector &v) | |
void | set (const GKPoint &p1, const GKPoint &p2) |
GKLine | parallelLineAtDist (const GKPoint &p1, const GKPoint &p2, GK::RoadSide side, double dist) const |
GKLine | perpendicularLineAtPoint (const GKPoint &point) const |
bool | intersects (const GKLine &line2, GKPoint *point, double epsilon=0.001) const |
bool | intersectsPerpendicular (const GKPoint &p_per, GKPoint *p_intersec) const |
void | rotate (const GKPoint ¢er, double angle) |
GKCoord | angleBetweenLines (const GKLine &line2) const |
GKCoord | angleBetweenLinesComplete (const GKLine &line2) const |
bool | contains (const GKPoint &p, GKCoord epsilon=0.1) const |
GKCoord | distToPoint2D (const GKPoint &p) const |
Public Attributes | |
double | slope |
double | coef |
GKCoord | fromX |
GKCoord | fromY |
GKCoord | toX |
GKCoord | toY |
Class that defines a 2D line and contains methods for the most common greometrical operations over a line.
GKLine::GKLine | ( | ) |
GKLine::GKLine | ( | const GKPoint & | p1, |
GKCoord | slope | ||
) |
GKCoord GKLine::angleBetweenLines | ( | const GKLine & | line2 | ) | const |
Returns the minimum angle in radians ( between 0 and GKPI/2) this two lines make. If lines are parallel DBL_MAX is returned. If lines are the same 0 is returned.
GKCoord GKLine::angleBetweenLinesComplete | ( | const GKLine & | line2 | ) | const |
Returns the minimum angle in radians (between -GKPI and GKPI) this two lines make. If lines are parallel DBL_MAX is returned. If lines are the same 0 is returned.
bool GKLine::contains | ( | const GKPoint & | p, |
GKCoord | epsilon = 0.1 |
||
) | const |
It returns true if p is located inside the line or false otherwise.
GKCoord GKLine::distToPoint2D | ( | const GKPoint & | p | ) | const |
Returns the minimum distance from any point of the line to the point p.
If this and line2 intersect returns true and finds the intersection point p. Remember that lines perpendicular to the x axis are codified with slope = DBL_MAX and coef = x. Epsilon is the allowed difference between slopes to consider both lines parallel.
Returns true if there is a perpendicular line to this one that ges by p_per. If so, the point in this line that is the intersection (p_intersec) is also calculated and returned.
GKLine GKLine::parallelLineAtDist | ( | const GKPoint & | p1, |
const GKPoint & | p2, | ||
GK::RoadSide | side, | ||
double | dist | ||
) | const |
Given a vector in this line from p1 to p2, finds the parallel line at distance dist, either at the right (side = 0) or at the left side of the vector.
Returns the perpendicular line that goes by point. If this line is parallel to the x axis then the perpendicular that is returned is codified with slope = DBL_MAX and coef = point.x
void GKLine::rotate | ( | const GKPoint & | center, |
double | angle | ||
) |
Rotates this line modifying it using center as the rotation point and angle (value in radians) the angle of rotation. A positive angle will be a clokwise rotation (horaria) while a negative angle will be a counterclokwise rotation (anti-horaria).
Sets this line to be the one defined by these two points.
double GKLine::coef |
y = slope * x + coef. In case of a parallel line to the y axis, slope = FLT_MAX and coef = x.
GKCoord GKLine::fromX |
Segment coordinate that was used to create this line.
GKCoord GKLine::fromY |
Segment coordinate that was used to create this line.
double GKLine::slope |
line slope
GKCoord GKLine::toX |
Segment coordinate that was used to create this line.
GKCoord GKLine::toY |
Segment coordinate that was used to create this line.