PyANGKernel.GKPoints¶
- class GKPoints¶
Synopsis¶
Methods¶
def
__init__()def
add()def
angleToPoints()def
append()def
at()def
back()def
beforeLast()def
bufferize()def
capacity()def
center()def
centroid()def
clear()def
compress()def
constData()def
constFirst()def
constLast()def
contains2D()def
contains3D()def
count()def
cut()def
cutIn3()def
data()def
distToPoint2D()def
empty()def
expand()def
first()def
front()def
getAltitude()def
getArea()def
getConvexHull()def
getSlope()def
hasSlope()def
insert()def
intersects2D()def
isConvex()def
isEmpty()def
isSharedWith()def
last()def
leftOf()def
length()def
length2D()def
length3D()def
max_size()def
mid()def
move()def
onPolyline()def
__ne__()def
__add__()def
__iadd__()def
__lt__()def
__lshift__()def
__le__()def
__eq__()def
__gt__()def
__ge__()def
operator[]()def
order()def
pointAtPos()def
pop_back()def
pop_front()def
posAtPoint()def
prepend()def
push_back()def
push_front()def
remove()def
removeAll()def
removeAt()def
removeFirst()def
removeLast()def
removeOne()def
reserve()def
resize()def
reverse()def
rightOf()def
rotate()def
scale()def
second()def
segmentAtPoint()def
segmentAtPos()def
setAltitude()def
shrink_to_fit()def
size()def
sliced()def
squeeze()def
swap()def
swapItemsAt()def
takeAt()def
toList()def
toRectangle()def
toVector()def
translate()def
value()
Static functions¶
def
fromList()def
fromQtVector()def
fromVector()def
maxSize()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
This Vector of
GKPointsadds 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.- class GKPointsCompressType¶
- PyANGKernel.GKPoints.gkDefaultBezierPoints¶
- PyANGKernel.GKPoints.gkDefaultBezierPointsEpsilon¶
- __init__()¶
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(offsetPercent)
- Parameters:
offsetPercent – float
- Return type:
Adds a new point to this polyline at distance offsetPercent *
length2Dfrom the beginning. Returns the new point position. If offsetPercent <= 0.0 or offsetPercent >= 1.0 or polyline.size() < 2, it returns -1.- allIntersections(from, to, closed)¶
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(p1, p2, p3, p4)¶
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
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(l)
- Parameters:
l – .list of GKPoint
Returns the before last point (a.k.a “penultimate”).
- bufferize([_width=0.1[, _closed=true]])¶
- Parameters:
_width – float
_closed – bool
- Return type:
Scales the current points vector,
- calculateBezier(bezier[, nbmaxpoints=0[, simplify=true]])¶
- Parameters:
bezier –
GKPointsnbmaxpoints – int
simplify – bool
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 nbpoints. The bezier will be simplified using epsilon as the minimum distance allowed between points not to be discarded
If nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
If epsilon is -1 then the value of GKPoints::gkDefaultBezierPointsEpsilon will be used.
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 ); length = points.legth2D();
if nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
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, nbPoints ); length = points.legth3D();
if nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
Returns the center of this closed polygon.
Returns the centroid of this closed polygon.
- clear()¶
- compress(sizeToReduce, type)¶
- Parameters:
sizeToReduce – float
type –
GKPointsCompressType
- Return type:
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.
- computeProjectionIntervalPoints(secondPoints, initial, final)¶
Computes the initial and final projection points of the given “secondPoints” polyline over the current polyline. Returns true if there is at least one point projected, false is returned otherwise. If the return is false the initial and final parameters are set to GKPoint::null.
- computeProjectionIntervalPositions(secondPoints, initial, final)¶
Computes the initial and final projection positions of the given “secondPoints” polyline over the current polyline. Returns true if there is at least one point projected, false is returned otherwise. If the return is false the initial and final parameters are not changed.
- contains2D(point[, epsilon=0.01[, checkEdges=false]])¶
If this
GKPointsis a polygon (it’s closed), returns true if p is inside it.If this
GKPointsis a polygon (it’s closed), returns true if p is inside it in 3D.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(distance, leftPart, rightPart)
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(distanceIni, distanceEnd, leftPart, midPart, rightPart)¶
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/MMUnknownCommand (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.It returns the minimum distance from the
GKPointssegments to the input point p. IfGKPointshas a single point, it returns the 2D distance between that point and p. Finally, ifGKPointshas no points it returns GK::Inf.- expand(extraSize, type)¶
- Parameters:
extraSize – float
type –
GKPointsCompressType
- Return type:
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.
- first(n)
- Parameters:
n – int
- Return type:
.list of GKPoint
Returns
GKPointsdepth copy from QtVectorReturns the lower Z of any point of this polyline
Returns the area of the polygon described by this array of points. Assumes points are all at z = 0.
Gets the convexhull of the collection of points
- getParallelPolyline(side, distance)¶
Returns a parallel polyline to this at a distance “distance” on the specified side (side = 1 LEFT, side = 0 RIGHT)
- getParallelPolylineExtended(side, distance, extendedLength)¶
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(pos, side, distance)¶
Returns the position in the parallel polyline to this at a distance “distance” on the specified side (side = 1 LEFT, side = 0 RIGHT) of the point perpendicular to the one located at pos in this polyline.
Returns the polygon formed by the parallel polylines at distance “width/2” on each side of the given polyline, taking it as the central polilyne of the polygon. This is usefull for roads or lane geometry.
Finds 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”
- getPolylineOnPolyline(from, to)
- Parameters:
from – int
to – int
- Return type:
Finds 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”
- getProjectionPointsPosition(secondPoints)¶
- Parameters:
secondPoints –
GKPoints- Return type:
.list of double
Returns the positions on this polyline of the projections of each point from the given polyline.
It returns the slope for the segment ‘segmentPos’ that is, between point at ‘segmentPos’ and point at ‘segmentPos+1’
- getSlope(pointPos1, pointPos2)
- Parameters:
pointPos1 – int
pointPos2 – int
- Return type:
It returns the slope for the segment definet by ‘pointPos1’ and ‘pointPos2’. Warning: Position must exist or crash.
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.
- intersects2D(poli2[, includeVertexs=true[, closed=true[, resPoint=None]]])¶
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 NULL (so it’s a pointer to a valid
GKPoint)- intersects2D(from, to[, resPoint=None[, considerThisAsClosed=false[, includeVertexs=true]]])
Returns true if the line [from,to] intersects this object. The intersection point is returned in resPoint if resPoint is not NULL (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.Returns true if the points define a convex polygon.
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
- Parameters:
other – .list of GKPoint
- Return type:
- last(n)
- Parameters:
n – int
- Return type:
.list of GKPoint
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.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(pointIni, pointEnd)¶
- Parameters:
pointIni – int
pointEnd – int
- Return type:
Returns the length of the segments from pointIni to pointEnd (both inclusive). pointIni and pointEnd go from 0 to nbpoints in the polyline-1
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.
Returns a vector whose elements are copied from this vector, starting at position pos. If length is -1 (the default), all elements after pos are copied
- move(from, to)¶
- Parameters:
from – int
to – int
- onPolyline(point, epsilon[, closed=false])¶
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
segmentAtPosbut considering an epsilon.- 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.
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(secondPoints)¶
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
GKPointswill be returned, just one set ofGKPointsdefining a closed polygon or a group of closed polygons.- polylineIntersection(secondPoints)¶
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
GKPointswill be returned, just one set ofGKPointsor several groups ofGKPoints.- pop_back()¶
- pop_front()¶
- posAtPoint(p[, maxDistToPoints=0.01[, closed=false]])¶
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.
- remove(i[, n=1])¶
- Parameters:
i – int
n – int
- removeAt(i)¶
- Parameters:
i – int
- removeFirst()¶
Returns a new group of points with the same number of points, in the same order and just taking out the points that make the edges intersect and substituting them by the point located in the middle of both taken out points. So, let’s say that segment with point 0 and point 1 intersects with segment with point 2 and 3, then, point 1 and 2 will be taken out and substituted by a new point that is located in the middle of the line that point 2 and 3 made. This point will be added twice to get a group of points with the same number of points as the original one
- removeLast()¶
- reserve(size)¶
- Parameters:
size – int
- resize(size)¶
- Parameters:
size – int
- resizeForOverwrite(size)¶
- Parameters:
size – int
- reverse()¶
Reverses the points order.
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.Rotates all the points in this polyline an angle ‘angle’ in radians taking ‘center’ as the center of rotation
Scales all the points in this polyline multiplying all them by a scale point
Returns the second point (index == 1).
- segmentAtPoint(seg_res, p[, maxDistToPoints=0.5])¶
Returns the position in the vector of points that identifies the initial point of the segment where p is located or -1 if p is outside this group of points. If p is inside this group of points it also updates the segment “seg_res” with the ith and (i+1)th points if p is inside the ith segment. The point can be outside of the center line at a maximum distance “maxDistToPoints” from it to return true.
- segmentAtPos(pos[, closed=false[, length=None]])¶
- Parameters:
pos – float
closed – bool
length –
double
- Return type:
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 NULL (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(value)¶
- Parameters:
value – float
Moves the Z coords of this polyline to make the lower Z equal to “value”
- shrink_to_fit()¶
- simplifyPolyline([distance=0.00001])¶
- Parameters:
distance – float
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.
- sliced(pos, n)
- Parameters:
pos – int
n – int
- Return type:
.list of GKPoint
- squeeze()¶
- swap(other)¶
- Parameters:
other – .list of GKPoint
- swapItemsAt(i, j)¶
- Parameters:
i – int
j – int
Returns the 4 points that form a rectangle rotated angle degrees from the horizontal and containing all the points in this object
Returns the 4 points that form a rectangle rotated angle degrees from the horizontal and containing all the points in this object and all the points in otherPol
Applies a translation delta to all the points in this polyline
- translateFromCS(CS)¶
- Parameters:
CS – str
Translates an object from a Coordinate System