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

Public Member Functions

 GKSegment ()
 
 GKSegment (const GKPoint &from, const GKPoint &to)
 
void set (const GKPoint &p1, const GKPoint &p2)
 
bool intersects2D (const GKSegment &segment2, GKPoint *inter=NULL, bool includeVertexs=true, double epsilon=0.001) const
 
GKPoints toRectangle (double width) const
 
bool onSegment2D (const GKPoint &p, double epsilon, bool useVertexs=true) const
 
GKPoint pointAtDist (double dist) const
 
GKPoint pointAtDist2D (double dist) const
 
GKSegment parallelDist (GK::RoadSide side, double dist) const
 
bool onSegment3D (const GKPoint &p, double epsilon) const
 
GKCoord distToPoint2D (const GKPoint &p, GKPoint *resPoint=NULL) const
 
GKCoord distToPoint3D (const GKPoint &p) const
 
void rotate (const GKPoint &center, GKCoord angle)
 
void translate (const GKPoint &delta)
 
void expand2D (GKCoord factor)
 
GKCoord getLength2D () const
 
GKCoord getLength3D () const
 
bool isPointAtRight (const GKPoint &p, double epsilon) const
 
bool isPointAtLeft (const GKPoint &p, double epsilon) const
 
bool isPointAtRightArea (const GKPoint &p) const
 
GKCoord normalizedDistance2D (const GKPoint &p) const
 
double angleBetweenSegments (const GKSegment &segment) const
 
GKPoint getPointProjection (const GKPoint &point)
 
GKPoint getExpandedPointByLength (const GKPoint &point, double length)
 
GKPoint getPointByLength (const GKPoint &point, double length)
 
GKPoint getPerpendicularIntersectionPoint (const GKPoint &point, const GKSegment &segmentC)
 

Public Attributes

GKPoint from
 
GKPoint to
 

Detailed Description

These points can contain the (x, y, z) coordinates. It can be used to contain a 2d segment as most of the methods for points have a default z value assigned to 0.

Constructor & Destructor Documentation

◆ GKSegment() [1/2]

GKSegment::GKSegment ( )

Creates a going with both initial and ending points set at (0, 0)

◆ GKSegment() [2/2]

GKSegment::GKSegment ( const GKPoint from,
const GKPoint to 
)

Creates a segment defining the initial (from) and end (to) points of this segment

Member Function Documentation

◆ angleBetweenSegments()

double GKSegment::angleBetweenSegments ( const GKSegment segment) const

It returns the angle between this segment and the segment 'segment' in radians between (-GKPI, GKPI). The convention followed is: the angle is positive if from the first segment to the second one the direction is counterclockwise. If the segments are parallel it returns 0.0

◆ distToPoint2D()

GKCoord GKSegment::distToPoint2D ( const GKPoint p,
GKPoint resPoint = NULL 
) const

Returns the minimum distance from any point of the segment to the point p

◆ distToPoint3D()

GKCoord GKSegment::distToPoint3D ( const GKPoint p) const

Returns the minimum distance from any point of the segment to the point p

◆ expand2D()

void GKSegment::expand2D ( GKCoord  factor)

It enlarges the segment a distance equal to factor*segmentLength in each extreme. That is, when factor is 2 it will be added a part equal to twice the segment's length in each end of the segment.

◆ getExpandedPointByLength()

GKPoint GKSegment::getExpandedPointByLength ( const GKPoint point,
double  length 
)

getExpandedPointByLength. Finds the coordinates of the point, which belongs to the line (and is a prolongation of the segment) and the distance between it and the initial point equals to length

Parameters
point- initial point
length- length between the initial point and the point we want to find
Returns
the expanded point

◆ getLength2D()

GKCoord GKSegment::getLength2D ( ) const

It returns the segment's length taking into account only the x and y coordinates

◆ getLength3D()

GKCoord GKSegment::getLength3D ( ) const

It returns the segment's length taking into account all 3 coordinates (x, y and z)

◆ getPerpendicularIntersectionPoint()

GKPoint GKSegment::getPerpendicularIntersectionPoint ( const GKPoint point,
const GKSegment segmentC 
)

getPerpendicularIntersectionPoint. Finds intersection point of a perpendicular to the segmentC (going through the point) with an initial segment

Parameters
point- a point from which a perpendicular goes
segmentC- segment to which we find a perpendicular
Returns
the coordinates of intersection

◆ getPointByLength()

GKPoint GKSegment::getPointByLength ( const GKPoint point,
double  length 
)

getPointByLength. Finds the coordinates of the point, which belongs to the segment and the distance between it and the initial point equals to length

Parameters
point- initial point
length- length between the initial point and the point we want to find
Returns
the found point

◆ getPointProjection()

GKPoint GKSegment::getPointProjection ( const GKPoint point)

getPointProjection. Returns a projection of the point to the line that goes through the segment

Parameters
point- initial point
Returns
- a projection point

◆ intersects2D()

bool GKSegment::intersects2D ( const GKSegment segment2,
GKPoint inter = NULL,
bool  includeVertexs = true,
double  epsilon = 0.001 
) const

It returns true if this segment intersects with segment2. If inter is provided the intersection point, if any, will be also returned. If includeVertexs is true, if the intersection point is one of the segment's vertexes then true will also be returned. Epsilon is the error difference allowed to consider two values equal.

◆ isPointAtLeft()

bool GKSegment::isPointAtLeft ( const GKPoint p,
double  epsilon 
) const

It returns true when the point p is located on then imaginary line that appears expanding the segment and at the left side of the "from" point of the segment. It returns false otherwise. The epsilon is defined to set the accuracy of the point on the line, that is, the distance at which the point can be located outside the line and considered as inside

◆ isPointAtRight()

bool GKSegment::isPointAtRight ( const GKPoint p,
double  epsilon 
) const

It returns true when the point p is located on then imaginary line that appears expanding the segment and at the right side of the "to" point of the segment. It returns false otherwise. The epsilon is defined to set the accuracy of the point on the line, that is, the distance at which the point can be located outside the line and considered as inside

◆ isPointAtRightArea()

bool GKSegment::isPointAtRightArea ( const GKPoint p) const

It return true is p is located at the right area of the segment, and false otherwise. If only x and y corrdinates are taken into account, the vectorial product between the vector that goes from 'from' to 'p' and the vector that goes from 'from' to 'to' will have the z positive if true is returned

◆ normalizedDistance2D()

GKCoord GKSegment::normalizedDistance2D ( const GKPoint p) const

If the point p is in the segment then the value returned is between 0 and 1, 0 when p equals to "from" and 1 when p equals to "to". If p is in the segment line but outside the segment, it returns a value less than 0 when the nearest point is "from" and a value greater than 1 when the nearest point is "to".

◆ onSegment2D()

bool GKSegment::onSegment2D ( const GKPoint p,
double  epsilon,
bool  useVertexs = true 
) const

This function returns true if the point "p" is on the segment taking into account the coordinates in the 2D space and with a maximum distance 'epsilon' to the segment. If useVertexs is true and p is a vertex of the segment it will return true and false otherwise

◆ onSegment3D()

bool GKSegment::onSegment3D ( const GKPoint p,
double  epsilon 
) const

This function returns true if the point "p" is on the segment taking into account the coordinates in the 3D space and with a maximum distance 'epsilon' to the segment

◆ parallelDist()

GKSegment GKSegment::parallelDist ( GK::RoadSide  side,
double  dist 
) const

Finds the parallel segment at distance "dist", either at the right or at the left side.

◆ pointAtDist()

GKPoint GKSegment::pointAtDist ( double  dist) const

It finds the point in the segment located at distance "dist" from the beginning of the segment. Note that the beginning is the point called "from"

◆ pointAtDist2D()

GKPoint GKSegment::pointAtDist2D ( double  dist) const

It finds the point in the segment located at distance "dist" from the beginning of the segment, without taking into account the z coordinate, that is, in 2D. Note that the beginning is the point called "from"

◆ rotate()

void GKSegment::rotate ( const GKPoint center,
GKCoord  angle 
)

It rotates this segment "angle" radians using "center" as the center point of the rotation

◆ set()

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

It sets the initial and end points of the segment to p1 and p2 respectively

◆ toRectangle()

GKPoints GKSegment::toRectangle ( double  width) const

Converts the segment into a rectangle expanding it width/2.0 in all four rectangle faces

◆ translate()

void GKSegment::translate ( const GKPoint delta)

Applies a translation delta

Member Data Documentation

◆ from

GKPoint GKSegment::from

"from" is the point where the segment starts and "to" is the point where the segment ends

◆ to

GKPoint GKSegment::to

© Aimsun SLU
Aimsun ®