Aimsun Next Scripting
22
|
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 ¢er, 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 |
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.
GKSegment::GKSegment | ( | ) |
Creates a going with both initial and ending points set at (0, 0)
Creates a segment defining the initial (from) and end (to) points of this segment
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
Returns the minimum distance from any point of the segment to the point p
GKCoord GKSegment::distToPoint3D | ( | const GKPoint & | p | ) | const |
Returns the minimum distance from any point of the segment to the point p
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. 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
point | - initial point |
length | - length between the initial point and the point we want to find |
GKCoord GKSegment::getLength2D | ( | ) | const |
It returns the segment's length taking into account only the x and y coordinates
GKCoord GKSegment::getLength3D | ( | ) | const |
It returns the segment's length taking into account all 3 coordinates (x, y and z)
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
point | - a point from which a perpendicular goes |
segmentC | - segment to which we find a perpendicular |
getPointByLength. Finds the coordinates of the point, which belongs to the segment and the distance between it and the initial point equals to length
point | - initial point |
length | - length between the initial point and the point we want to find |
getPointProjection. Returns a projection of the point to the line that goes through the segment
point | - initial point |
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.
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
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
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
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".
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
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
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.
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"
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"
void GKSegment::rotate | ( | const GKPoint & | center, |
GKCoord | angle | ||
) |
It rotates this segment "angle" radians using "center" as the center point of the rotation
It sets the initial and end points of the segment to p1 and p2 respectively
GKPoints GKSegment::toRectangle | ( | double | width | ) | const |
Converts the segment into a rectangle expanding it width/2.0 in all four rectangle faces
void GKSegment::translate | ( | const GKPoint & | delta | ) |
Applies a translation delta
GKPoint GKSegment::from |
"from" is the point where the segment starts and "to" is the point where the segment ends
GKPoint GKSegment::to |