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

Inheritance diagram of PyANGKernel.GKBezierCurve

Inherited by: GKTurning, GKSuperNodeTrajectory, GKSection, GKObjectConnection, GKCenConnection

Synopsis

Methods

Virtual methods

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:

rhsGKBezierCurve

MeanRadius([nbpoints=0])
Parameters:

nbpoints – int

Return type:

float

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.

addCurvePointAt(pos, p)
Parameters:

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:

typeGKBezierCurveType

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:

curveGKBezierCurve

Return type:

float

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

calculateBezierDerivative(t)
Parameters:

t – float

Return type:

GKVector

Computes the derivative of a Bezier section using the value of the parametrized variable

calculateBezierPoint(t)
Parameters:

t – float

Return type:

GKPoint

Computes the point of a Bezier section using the value of the parametrized variable.

calculateBezierRadius(p[, nbpoints=0])
Parameters:
Return type:

float

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.

calculateBezierSecondDerivative(t)
Parameters:

t – float

Return type:

GKVector

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

  • segmentsBeginPosQList

Return type:

GKPoints

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

  • segmentsBeginPosQList

Return type:

GKPoints

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.

getBezierCurvatureRadius(tpoint)
Parameters:

tpoint – float

Return type:

float

Computes the radius of a Bezier section at a given curvilinear coord t.

getBezierRadiusatPoint(p, p1[, nbpoints=0])
Parameters:
Return type:

float

Computes the radius of a Bezier section at a given point of the section.

getCurveType(pos)
Parameters:

pos – int

Return type:

GKBezierCurveType

Returns the curve type of the point at the specified pos.

getNbSegments()
Return type:

int

Return the number of segments. Equivalent to:

getSegments().size();

See also

getSegments()

getNumSegmentControlPoints(pos)
Parameters:

pos – int

Return type:

int

Returns the number of control points for one and only one of the segments of this curve.

getSegment(pos)
Parameters:

pos – int

Return type:

GKBezierCurve

Retuns a curve for one and only one of the segments of this curve.

getSegmentLength(pos[, nbpoints=0])
Parameters:
  • pos – int

  • nbpoints – int

Return type:

float

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(p, epsilon)
Parameters:
Return type:

bool

Hit: is p over the curve?

isASegment()
Return type:

bool

Returns true is this object is a segment (it has a single segment and it is of type: eSegment).

length2D(nbpoints)
Parameters:

nbpoints – int

Return type:

float

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.

length3D(nbpoints)
Parameters:

nbpoints – int

Return type:

float

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.

nbParts()
Return type:

int

onlyContainsSegments()
Return type:

bool

Returns true is this object only contains segments.

pointAtPos(pos)
Parameters:

pos – float

Return type:

GKPoint

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])
Parameters:
  • pGKPoint

  • maxDistToCurve – float

Return type:

float

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.

segmentAtPos(pos[, length=None])
Parameters:
  • pos – float

  • lengthdouble

Return type:

int

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])
Parameters:
  • pointsGKPoints

  • pos – float

  • retLengthdouble

Return type:

int

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:

curveGKBezierCurve

Copies a curve geometry on this curve.

setFromPoints(ps, type)
Parameters:

Create a curve geometry from a polyline

setFromSegment(p1, p2, type)
Parameters:

Create a curve geometry from two points

setPoint(s, i, p)
Parameters:
  • s – int

  • i – int

  • pGKPoint

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.

toPointsArray()
Return type:

.list of GKPoints

Get the geometry as a vector of Points. The size of the points determines the segment type.