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

Public Types

enum  GKPointsCompressType { eStart , eEnd , eBoth }
 

Public Member Functions

 GKPoints ()
 
GKCoord length2D (bool closed=false) const
 
GKCoord length3D (bool closed=false) const
 
GKCoord length2DFromPointToPoint (int pointIni, int pointEnd) const
 
GKPoints leftOf (double distance) const
 
GKPoints rightOf (double distance) const
 
void cut (double distance, GKPoints &leftPart, GKPoints &rightPart) const
 
void cut (const GKPoint &p, GKPoints &leftPart, GKPoints &rightPart) const
 
int add (double offsetPercent)
 
void cutIn3 (GKCoord distanceIni, GKCoord distanceEnd, GKPoints &leftPart, GKPoints &midPart, GKPoints &rightPart) const
 
GKCoord getAltitude () const
 
void setAltitude (GKCoord value)
 
bool contains2D (const GKPoint &point, double epsilon=0.01, bool checkEdges=false) const
 
bool contains3D (const GKPoint &point, double epsilon=0.01) const
 
bool intersects2D (const GKPoints &poli2, bool includeVertexs=true, bool closed=true, GKPoint *resPoint=NULL) const
 
bool intersects2D (const GKPoint &from, const GKPoint &to, GKPoint *resPoint=NULL, bool considerThisAsClosed=false, bool includeVertexs=true) const
 
GKPoints allIntersections (const GKPoint &from, const GKPoint &to, bool closed) const
 
QVector< GKPointspolygonIntersection (const GKPoints &secondPoints) const
 
QVector< GKPointspolylineIntersection (const GKPoints &secondPoints) const
 
void translate (const GKPoint &delta)
 
void rotate (const GKPoint &center, double angle)
 
void scale (const GKPoint &scale)
 
int onPolyline (const GKPoint &point, double epsilon, bool closed=false) const
 
GKPoints getParallelPolyline (GK::RoadSide side, double distance) const
 
GKPoints getParallelPolylineExtended (GK::RoadSide side, double distance, double extendedLength) const
 
GKPoints getPolylineOnPolyline (double from, double to) const
 
GKPoints getConvexHull () const
 
double angleToPoints (const GKPoints &pointsTo) const
 
double angleBetweenLines (const GKPoint &p1, const GKPoint &p2, const GKPoint &p3, const GKPoint &p4) const
 
void simplifyPolyline (double distance=0.00001)
 
GKPoint pointAtPos (double pos, bool closed=false) const
 
double posAtPoint (const GKPoint &p, GKCoord maxDistToPoints=0.01, bool closed=false) const
 
int segmentAtPos (GKCoord pos, bool closed=false, double *length=NULL) const
 
GKPoint center () const
 
GKPoint centroid () const
 
void calculateBezier (GKPoints &bezier, uint nbmaxpoints=0, bool simplify=true) const
 
GKCoord calculateBezierLength2D (uint nbmaxpoints=0) const
 
GKCoord calculateBezierLength3D (uint nbmaxpoints=0) const
 
GKPoints compress (GKCoord sizeToReduce, GKPointsCompressType type) const
 
GKPoints expand (GKCoord extraSize, GKPointsCompressType type) const
 
void add (const GKPoints &points2)
 
void order ()
 
double getParallelPosAtDist (double pos, GK::RoadSide side, double distance) const
 
bool isPointAtRightArea (const GKPoint &p) const
 
double getArea () const
 
GKCoord getSlope (int segmentPos) const
 
GKCoord getSlope (int pointPos1, int pointPos2) const
 
bool hasSlope () const
 
GKCoord distToPoint2D (const GKPoint &p) const
 
void reverse ()
 
int __len__ ()
 
End GKPointoperator[] (int)
 
 if ((a0=sipConvertFromSequenceIndex(a0, len))< 0)
 
End void append (const GKPoint &p)
 

Public Attributes

MethodCode sipRes = sipCpp->size()
 
MethodCode int len
 
 len = sipCpp ->size()
 
 else
 
MethodCode sipCpp appenda0
 

Static Public Attributes

static uint gkDefaultBezierPoints
 
static double gkDefaultBezierPointsEpsilon
 

Detailed Description

This Vector of GKPoints adds methods to the collection of points that operates all over points. These methods are oriented to the collection of points not to a single point.

Member Enumeration Documentation

◆ GKPointsCompressType

Enumerator
eStart 
eEnd 
eBoth 

Constructor & Destructor Documentation

◆ GKPoints()

GKPoints::GKPoints ( )

Member Function Documentation

◆ __len__()

int GKPoints::__len__ ( )

◆ add() [1/2]

void GKPoints::add ( const GKPoints points2)

This function returns a new polygon constructed adding points2 to this. This function mix the points from both polygons adding each point in order taken into account the angle that the line center-point makes with the horizontal. The current polygon (or set of points) is modified.

◆ add() [2/2]

int GKPoints::add ( double  offsetPercent)

Adds a new point to this polyline at distance offsetPercent * length2D from the beginning. Returns the new point position. If offsetPercent <= 0.0 or offsetPercent >= 1.0 or polyline.size() < 2, it returns -1.

◆ allIntersections()

GKPoints GKPoints::allIntersections ( const GKPoint from,
const GKPoint to,
bool  closed 
) const

Returns all the intersections of the line [from,to] with this object. If closed is true the this object is interpreted as a Polygon, if not as a Polyline

◆ angleBetweenLines()

double GKPoints::angleBetweenLines ( const GKPoint p1,
const GKPoint p2,
const GKPoint p3,
const GKPoint p4 
) const

It returns the angle between the lines (from p1 to p2) and (from p3 to p4) in radians between (-GKPI, GKPI). The convention followed is: the angle is positive if from the first line to the second one the direction is counterclockwise. If the lines are parallel lines it returns 0.0

◆ angleToPoints()

double GKPoints::angleToPoints ( const GKPoints pointsTo) const

It returns the angle between the two last points of this object and the two first points in 'pointsTo' in radians between (-GKPI, GKPI). The convention followed is: the angle is positive if from the first line to the second one the direction is counterclockwise. If the lines are parallel lines it returns 0.0

◆ append()

End void GKPoints::append ( const GKPoint p)

◆ calculateBezier()

void GKPoints::calculateBezier ( GKPoints bezier,
uint  nbmaxpoints = 0,
bool  simplify = true 
) const

Calculates a polyline that represents a bezier curve with "this" as control points of the bezier curve. The result is stored in bezier. The bezier will have as much points as nbmaxpoints. The bezier will be simplified if simplify is true and then using epsilon as the minimum distance allowed between points not to be discarded.

if nbmaxpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used. 

◆ calculateBezierLength2D()

GKCoord GKPoints::calculateBezierLength2D ( uint  nbmaxpoints = 0) const

Calculates the length 2D of the polyline that represents a bezier curve with "this" as control points of the bezier curve Equivaled, but faster than, to:

calculateBezier( points, nbmaxpoints, simplify )
length = points.legth2D()
void calculateBezier(GKPoints &bezier, uint nbmaxpoints=0, bool simplify=true) const

if nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.

◆ calculateBezierLength3D()

GKCoord GKPoints::calculateBezierLength3D ( uint  nbmaxpoints = 0) const

Calculates the length 3D of the polyline that represents a bezier curve with "this" as control points of the bezier curve Equivaled, but faster than, to:

calculateBezier( points, nbmaxpoints, simplify )
length = points.legth3D()

if nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.

◆ center()

GKPoint GKPoints::center ( ) const

Returns the center of this closed polygon.

◆ centroid()

GKPoint GKPoints::centroid ( ) const

Returns the centroid of this closed polygon.

◆ compress()

GKPoints GKPoints::compress ( GKCoord  sizeToReduce,
GKPointsCompressType  type 
) const

Returns a compressed version of this polyline (this method doesn't works on polygons). It reduce the length of the polyline in "sizeToReduce" m. The reduction on each segment is proportional to each segment length.

The reduction type can be:

  • eStart: reduces from the start point (included), all the points except the end point are changed.
  • eEnd: reduces from the end point (included), all the points except the start point are changed.
  • eBoth: reduces all the segments. All the points are changed.

◆ contains2D()

bool GKPoints::contains2D ( const GKPoint point,
double  epsilon = 0.01,
bool  checkEdges = false 
) const

If this GKPoints is a polygon (it's closed), returns true if p is inside it.

◆ contains3D()

bool GKPoints::contains3D ( const GKPoint point,
double  epsilon = 0.01 
) const

If this GKPoints is a polygon (it's closed), returns true if p is inside it in 3D.

◆ cut() [1/2]

void GKPoints::cut ( const GKPoint p,
GKPoints leftPart,
GKPoints rightPart 
) const

Calculates the left and right part of this polyline based on a cut point. LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point p, R: right part).

The cut point (p) will be part of left and right parts.

◆ cut() [2/2]

void GKPoints::cut ( double  distance,
GKPoints leftPart,
GKPoints rightPart 
) const

Calculates the left and right part of this polyline based on distance (the beginning of the polysection is at a distance 0.0): LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point at distance, R: right part). The cut point (at distance) will be part of left and right parts.

If distance is negative then distance = this->length2D() + distance.

◆ cutIn3()

void GKPoints::cutIn3 ( GKCoord  distanceIni,
GKCoord  distanceEnd,
GKPoints leftPart,
GKPoints midPart,
GKPoints rightPart 
) const

Calculates the left, middle and right part of this polyline based on two distances (the beginning of the polysection is at a distance 0.0). Both distances are from the beginning of the polyline: LLLLLLL/MM\RRRRRRR (L: left part, /:point at distanceIni, M: Middle part, \:point at distanceEnd (>distanceIni) R: right part). The cut points (at distanceIni and distanceEnd) will be part of both parts.

If distance is negative then distance = this->length2D() + distance.

◆ distToPoint2D()

GKCoord GKPoints::distToPoint2D ( const GKPoint p) const

Returns the minimum distance from any point of the group of points to the point p

◆ expand()

GKPoints GKPoints::expand ( GKCoord  extraSize,
GKPointsCompressType  type 
) const

Returns a expanded version of this polyline (this method doesn't works on polygons). It expand the length of the polyline in "extraSize" m.

The expand type can be:

  • eStart: expands from the start point (included), only the start point is changed.
  • eEnd: expands from the end point (included), only the end point is changed.

◆ getAltitude()

GKCoord GKPoints::getAltitude ( ) const

Returns the lower Z of any point of this polyline.

◆ getArea()

double GKPoints::getArea ( ) const

Returns the area of the polygon described by this array of points. Assumes points are all at z = 0.

◆ getConvexHull()

GKPoints GKPoints::getConvexHull ( ) const

Gets the convexhull of the collection of points

◆ getParallelPolyline()

GKPoints GKPoints::getParallelPolyline ( GK::RoadSide  side,
double  distance 
) const

Returns a parallel polyline to this at a distance "distance" on the specified side

◆ getParallelPolylineExtended()

GKPoints GKPoints::getParallelPolylineExtended ( GK::RoadSide  side,
double  distance,
double  extendedLength 
) const

Returns a parallel polyline to this at a distance "distance" on the specified side (side = 1 LEFT, side = 0 RIGHT) and with an extra segment at the beginning and at the end of extendedLength

◆ getParallelPosAtDist()

double GKPoints::getParallelPosAtDist ( double  pos,
GK::RoadSide  side,
double  distance 
) const

Returns the position in the parallel polyline to this at a distance "distance" on the specified side of the point perpendicular to the one located at pos in this polyline.

◆ getPolylineOnPolyline()

GKPoints GKPoints::getPolylineOnPolyline ( double  from,
double  to 
) const

Founds the polyline over this polyline that starts at a distance of "from" from the beginning of the "polyline" and ends at a distance of "to" again from the beginning of the "polyline"

◆ getSlope() [1/2]

GKCoord GKPoints::getSlope ( int  pointPos1,
int  pointPos2 
) const

It returns the slope for the segment definet by 'pointPos1' and 'pointPos2'. Warming: Position must exist or crash.

◆ getSlope() [2/2]

GKCoord GKPoints::getSlope ( int  segmentPos) const

It returns the slope for the segment 'segmentPos' that is, between point at 'segmentPos' and point at 'segmentPos+1'

◆ hasSlope()

bool GKPoints::hasSlope ( ) const

It returns true if at least two point are at a different height. It returns false if all the points are at the same height.

◆ if()

GKPoints::if ( )
inline

◆ intersects2D() [1/2]

bool GKPoints::intersects2D ( const GKPoint from,
const GKPoint to,
GKPoint resPoint = NULL,
bool  considerThisAsClosed = false,
bool  includeVertexs = true 
) const

Returns true if the line [from,to] intersects this object. The intersection point is returned in resPoint if resPoint is not None (so it's a pointer to a valid GKPoint). It considerThisAsClosed is true then the segment between the last point and the first one is also considered. includeVertexs variable indicates if intersections on the vertexs have to be taken into account or not.

◆ intersects2D() [2/2]

bool GKPoints::intersects2D ( const GKPoints poli2,
bool  includeVertexs = true,
bool  closed = true,
GKPoint resPoint = NULL 
) const

Returns true if poli2 (polygon if closed = true or polyline if closed = false ) intersects with this object. If this object and poly2 have only vertexs in commom it will return true if include vertexs is true and false if includeVertexs is false. The intersection point is returned in resPoint if resPoint is not None (so it's a pointer to a valid GKPoint)

◆ isPointAtRightArea()

bool GKPoints::isPointAtRightArea ( const GKPoint p) const

Returns true if point p is located at the right side of this polyline (right going from the first point to the last one) and false if p is located at the left side

◆ leftOf()

GKPoints GKPoints::leftOf ( double  distance) const

Returns the left part of this polyline based on distance (the beginning of the polysection is at a distance 0.0): LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point at distance, R: right part). The cut point (at distance) will be part of left and right parts.

If distance is negative then distance = this->length2D() + distance.

◆ length2D()

GKCoord GKPoints::length2D ( bool  closed = false) const

Returns the length of the polyline represented by this points in a 2D space (the Z coordinate is not used). If closed is true then the segment from the last point to the first point is considered.

◆ length2DFromPointToPoint()

GKCoord GKPoints::length2DFromPointToPoint ( int  pointIni,
int  pointEnd 
) const

Returns the length of the segments from pointIni to pointEnd (both inclusive). pointIni and pointEnd go from 0 to nbpoints in the polyline-1

◆ length3D()

GKCoord GKPoints::length3D ( bool  closed = false) const

Returns the length of this polyline in a 3D space. If closed is true then the segment from the last point to the first point is considered.

◆ onPolyline()

int GKPoints::onPolyline ( const GKPoint point,
double  epsilon,
bool  closed = false 
) const

Returns the segment number where the point "point" is. If closed is true then the segment from the last point to the first point is considered.

This method is similar to GKPoints::segmentAtPos but considering an epsilon.

◆ operator[]()

End GKPoint * GKPoints::operator[] ( int  )

◆ order()

void GKPoints::order ( )

This function orders the points taken into account the angle that the line center-point makes with the horizontal. The current polygon (or set of points) is modified.

◆ pointAtPos()

GKPoint GKPoints::pointAtPos ( double  pos,
bool  closed = false 
) const

Returns the point in the polyline at position "pos" relative to its start (pos = 0.0 is the start point, pos = length2D() is the end point). Is pos is negative then it will take as initial reference the last point, so it these two calls are equivalent: line.pointAtPos( -3.0 ) and line.pointAtPos( line.length2D() - 3.0 ).

If closed is true then the segment from the last point to the first point is considered.

◆ polygonIntersection()

QVector< GKPoints > GKPoints::polygonIntersection ( const GKPoints secondPoints) const

Returns a set of polygons that define the intersection polygons between this and the secondPoints group of points. The intersection can be none, then an empty GKPoints will be returned, just one set of GKPoints defining a closed polygon or a group of closed polygons.

◆ polylineIntersection()

QVector< GKPoints > GKPoints::polylineIntersection ( const GKPoints secondPoints) const

Returns a set of polygons that define the intersection between this and the secondPoints group of points. The intersection can be none, then an empty GKPoints will be returned, just one set of GKPoints or several groups of GKPoints.

◆ posAtPoint()

double GKPoints::posAtPoint ( const GKPoint p,
GKCoord  maxDistToPoints = 0.01,
bool  closed = false 
) const

Returns the position in the polyline at point "p". The point can be outside of the center line at a maximum distance "maxDistToPoints" from it and, if so, the method will calculate the point at the more close segment (perpendicular to p) and will use this new point.

If closed is true then the segment from the last point to the first point is also considered.

◆ reverse()

void GKPoints::reverse ( )

Reverses the points order.

◆ rightOf()

GKPoints GKPoints::rightOf ( double  distance) const

Returns the right part of this polyline based on distance (the beginning of the polysection is at a distance 0.0): LLLLLLLLLLLLL/RRRRRRR (L: left part, /:point at distance, R: right part). The cut point (at distance) will be part of left and right parts.

If distance is negative then distance = this->length2D() + distance.

◆ rotate()

void GKPoints::rotate ( const GKPoint center,
double  angle 
)

Rotates all the points in this polyline an angle 'angle' in radians taking 'center' as the center of rotation

◆ scale()

void GKPoints::scale ( const GKPoint scale)

Scales all the points in this polyline multiplying all them by a scale point

◆ segmentAtPos()

int GKPoints::segmentAtPos ( GKCoord  pos,
bool  closed = false,
double *  length = NULL 
) const

Returns the position in the vector of points that identifies the initial point of the segment where the point at position "pos" relative to the start of the polyline is located (pos = 0.0 is the start point, pos = length2D() is the end point). The length of the 0 --> pos - 1 segments is returned too if "length" is not None (it's a pointer to a double).

Examples: This -> Polyline with 3 points: p[0], p[1], p[2] Distance between p[0] & p[1] = 1.0 Distance between p[1] & p[2] = 2.0

segmentAtPos(0.0) = 0 segmentAtPos(1.0) = 0 segmentAtPos(1.5) = 1 segmentAtPos(3.0) = 1

If closed is true then the segment from the last point to the first point is considered.

◆ setAltitude()

void GKPoints::setAltitude ( GKCoord  value)

Moves the Z coords of this polyline to make the lower Z equal to "value".

◆ simplifyPolyline()

void GKPoints::simplifyPolyline ( double  distance = 0.00001)

Removes all the unnecesary points, that is the ones that belong to the same segment as their precedent and posterior points, as well as all the loops found in the polyline.

Uses distance to consider points that are too close and must be eliminated.

◆ translate()

void GKPoints::translate ( const GKPoint delta)

Applies a translation delta to all the points in this polyline

Member Data Documentation

◆ a0

MethodCode sipCpp append* GKPoints::a0

◆ else

GKPoints::else
Initial value:
{
sipRes = &(*sipCpp)[a0]
MethodCode sipCpp append * a0
Definition: GKPoints.sip:347
MethodCode sipRes
Definition: GKPoints.sip:329

◆ gkDefaultBezierPoints

uint GKPoints::gkDefaultBezierPoints
static

Number of points to render a bezier curve. The default number is 10. A bigger number will produce smoother curves but using more memory.

◆ gkDefaultBezierPointsEpsilon

double GKPoints::gkDefaultBezierPointsEpsilon
static

Epsilon to control when points are discarded as they are too close (in a bezier curve).

◆ len [1/2]

MethodCode int GKPoints::len

◆ len [2/2]

GKPoints::len = sipCpp ->size()

◆ sipRes

MethodCode GKPoints::sipRes = sipCpp->size()

© Aimsun SLU
Aimsun ®