PyANGKernel.GKBezierCurve¶
- class GKBezierCurve¶
A collection of segments as bezier curves and straight segments.
Details
This class holds a set of consecutive, connected, segments. Each segment can be either a bezier curve or a straight segment. Its possible to mix these two types of segments.
Besides a straight segment, it support two types of curves: - Simple curve: a bezier curve with just one control point - Curve: a bezier curve with two control points
Inherited by:
GKTurning,GKSuperNodeTrajectory,GKSection,GKObjectConnection,GKCenConnectionSynopsis¶
Methods¶
def
__init__()def
MeanRadius()def
addSegment()def
angleToCurve()def
getCurveType()def
getNbSegments()def
getSegment()def
getSegments()def
hit()def
isASegment()def
length2D()def
length3D()def
nbParts()def
pointAtPos()def
posAtPoint()def
segmentAtPos()def
setPoint()def
setSegments()def
toPointsArray()
Virtual methods¶
def
removePoints()def
setCurve()def
setFromPoints()def
setFromSegment()
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
- class GKBezierCurveType¶
- __init__()¶
- __init__(rhs)
- Parameters:
rhs –
GKBezierCurve
Mean radius of this curve. Note that it uses discretization of the curve so it it’s an approximation and not the real mean radius. It will use “nbpoints” points to evaluate the curve. If nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
Add a point at position pos. This will convert a segment in a simple curve and a simple curve in a complex curve. In a complex curve a line segment will be created for this new point.
- addSegment(type)¶
- Parameters:
type –
GKBezierCurveType
Add a new segment. This call does not add any new point so it will be called always with methods that add points.
- angleToCurve(curve)¶
- Parameters:
curve –
GKBezierCurve- Return type:
This function returns the angle in radians (-GKPI, GKPI] between the last part of this bezier curve and the first part of the ‘curve’ given as parameter of the function. If it is necessary it calculates the polyline of both bezier curves. 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 and going in the same direction it returns 0.0
Computes the derivative of a Bezier section using the value of the parametrized variable
Computes the point of a Bezier section using the value of the parametrized variable.
Calculates the mean radius of a bezier section. Note that it discretizes the curve so it is an approximation and not the real minimum radius. If nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
Computes the second derivative of a Bezier section using the value of the parametrized variable.
- calculatePolyline([nbpoints=0[, simplify=true[, segmentsBeginPos=None]]])¶
- Parameters:
nbpoints – int
simplify – bool
segmentsBeginPos –
QList
- Return type:
Calculates a polyline that represents this
GKBezierCurve. The polyline is calculated in “points” and “points” are also returned.If segmentsBeginPos is not null in this vector (one entry by segment) the start position of each segment is returned (start position in the array of calculated points).
If nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
- calculatePolylineKeepingSegments([nbpoints=0[, segmentsBeginPos=None]])¶
- Parameters:
nbpoints – int
segmentsBeginPos –
QList
- Return type:
Calculates a polyline that represents a this
GKBezierCurve. The polyline is calculated in “points” and “points” is also returned.If segmentsBeginPos is not null in this vector (one entry by segment) the start position of each segment is returned (start position in the array of calculated points).
If nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
It keeps a least the initial and end point of each segment.
- fromPointsArray(segments)¶
- Parameters:
segments – .list of GKPoints
Set the geometry from a vector of Points. The size of the points determines the segment type.
Computes the radius of a Bezier section at a given curvilinear coord t.
- getBezierRadiusatPoint(p, p1[, nbpoints=0])¶
Computes the radius of a Bezier section at a given point of the section.
- getCurveType(pos)¶
- Parameters:
pos – int
- Return type:
Returns the curve type of the point at the specified pos.
Return the number of segments. Equivalent to:
getSegments().size();
See also
Returns the number of control points for one and only one of the segments of this curve.
- getSegment(pos)¶
- Parameters:
pos – int
- Return type:
Retuns a curve for one and only one of the segments of this curve.
Returns the length of the segment at “pos”. It will use nbpoints points to evaluate the segment if it is a curve.
If nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
- getSegments()¶
- Return type:
.list of GKBezierCurve.GKBezierCurveType
Return information about the type of segments that are part of this object.
Hit: is p over the curve?
Returns true is this object is a segment (it has a single segment and it is of type: eSegment).
Length of this curve in 2D. Note that it first converts the curve to a polyline so it is an approximation and not the real length. It will use “nbpoints” points to evaluate the curve.
If nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
Length of this curve. Note that it first converts the curve to a polyline so it is an approximation and not the real length. It will use “nbpoints” points to evaluate the curve.
If nbpoints is 0 then the value of GKPoints::gkDefaultBezierPoints will be used.
Returns true is this object only contains segments.
Returns the point in the center line at position “pos” relative to the start of the curve (pos = 0.0 is the start point, pos =
length2D()is the end point).- posAtPoint(p[, maxDistToCurve=0.01])¶
Returns the position in the center line at point “p”. The point can be outside of the center line at a maximum distance “maxDistToCurve” and, if so, the method will calculate the point at the closest segment (perpendicular to p) and will use this new point.
- removePoints(nbPoints, atStart, nbSegmentsRemoved)¶
- Parameters:
nbPoints – int
atStart – bool
nbSegmentsRemoved – int
Removes nbPoints from this curve either at the beginning (atStart = true) or at the end (atStart = false). The segments associated with these points will be removed too. It returns the number of segments removed in nbSegmentsRemoved.
Returns the segment in the center line at position “pos” relative to the start of the section (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.- segmentAtPosComplete(points, pos[, retLength=None])¶
Evaluates all the segments calculating their subsegments (if needed).
When a segment is eSegment the number subsegments is one. When a segment is eCurve or eSimpleCurve it is converted into GKPoints::gkDefaultBezierPoints subsegments.
Returns the subsegment in the center line at position “pos” relative to the start of the section (pos = 0.0 is the start point, pos =
length2D()is the end point). The length of the 0 –> pos - 1 subSegments is returned too if “retLength” is not null.- setCurve(curve)¶
- Parameters:
curve –
GKBezierCurve
Copies a curve geometry on this curve.
- setFromPoints(ps, type)¶
- Parameters:
ps –
GKPointstype –
GKBezierCurveType
Create a curve geometry from a polyline
- setFromSegment(p1, p2, type)¶
- Parameters:
p1 –
GKPointp2 –
GKPointtype –
GKBezierCurveType
Create a curve geometry from two points
Sets p as the i-th point of segment s. Segments are numbered from 0 to n-1. i can be 0 or 1 for straight segments; 0, 1 or 2 for simple curve segments and 0,1, 2 or 3 for cruve with two control points. The last point of one segment is the first point of the next segment so the last of these two points set will override the previous point if defined previously
- setSegments(segmentList)¶
- Parameters:
segmentList – .list of GKBezierCurve.GKBezierCurveType
Sets the segments for this curve. Since no point is added the next call must be setPoints.
Get the geometry as a vector of Points. The size of the points determines the segment type.