Aimsun Next Scripting: GKLine Class Reference
Aimsun Next Scripting  22
Public Member Functions | Public Attributes | List of all members
GKLine Class Reference

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 &center, 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
 

Detailed Description

Class that defines a 2D line and contains methods for the most common greometrical operations over a line.

Constructor & Destructor Documentation

◆ GKLine() [1/4]

GKLine::GKLine ( )

◆ GKLine() [2/4]

GKLine::GKLine ( const GKPoint p1,
const GKPoint p2 
)

◆ GKLine() [3/4]

GKLine::GKLine ( const GKPoint p1,
GKCoord  slope 
)

◆ GKLine() [4/4]

GKLine::GKLine ( const GKPoint p,
const GKVector v 
)

Member Function Documentation

◆ angleBetweenLines()

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.

◆ angleBetweenLinesComplete()

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.

◆ contains()

bool GKLine::contains ( const GKPoint p,
GKCoord  epsilon = 0.1 
) const

It returns true if p is located inside the line or false otherwise.

◆ distToPoint2D()

GKCoord GKLine::distToPoint2D ( const GKPoint p) const

Returns the minimum distance from any point of the line to the point p.

◆ intersects()

bool GKLine::intersects ( const GKLine line2,
GKPoint point,
double  epsilon = 0.001 
) const

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.

◆ intersectsPerpendicular()

bool GKLine::intersectsPerpendicular ( const GKPoint p_per,
GKPoint p_intersec 
) const

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.

◆ parallelLineAtDist()

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.

◆ perpendicularLineAtPoint()

GKLine GKLine::perpendicularLineAtPoint ( const GKPoint point) const

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

◆ rotate()

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).

◆ set()

void GKLine::set ( const GKPoint p1,
const GKPoint p2 
)

Sets this line to be the one defined by these two points.

Member Data Documentation

◆ coef

double GKLine::coef

y = slope * x + coef. In case of a parallel line to the y axis, slope = FLT_MAX and coef = x.

◆ fromX

GKCoord GKLine::fromX

Segment coordinate that was used to create this line.

◆ fromY

GKCoord GKLine::fromY

Segment coordinate that was used to create this line.

◆ slope

double GKLine::slope

line slope

◆ toX

GKCoord GKLine::toX

Segment coordinate that was used to create this line.

◆ toY

GKCoord GKLine::toY

Segment coordinate that was used to create this line.

© Aimsun SLU
Aimsun ®