Definition of curves in pyFormex.
This module defines classes and functions specialized for handling one-dimensional geometry in pyFormex. These may be straight lines, polylines, higher order curves and collections thereof. In general, the curves are 3D, but special cases may be created for handling plane curves.
Base class for curve type classes.
This is a virtual class intended to be subclassed. It defines the common definitions for all curve types. The subclasses should at least define the following:
sub_points(t,j)
Curve objects have the following methods:
Return the points at values t in part j
t can be an array of parameter values, j is a single segment number.
Return the points at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Returns the points at parameter values t.
Parameter values are floating point values. Their integer part is interpreted as the curve segment number, and the decimal part goes from 0 to 1 over the segment.
Return a series of points on the PolyLine.
The parameter space of each segment is divided into ndiv parts. The coordinates of the points at these parameter values are returned as a Coords object. The extend parameter allows to extend the curve beyond the endpoints. The normal parameter space of each part is [0.0 .. 1.0]. The extend parameter will add a curve with parameter space [-extend[0] .. 0.0] for the first part, and a curve with parameter space [1.0 .. 1 + extend[0]] for the last part. The parameter step in the extensions will be adjusted slightly so that the specified extension is a multiple of the step size. If the curve is closed, the extend parameter is disregarded.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
A class representing a series of straight line segments.
Initialize a PolyLine from a coordinate array.
coords is a (npts,3) shaped array of coordinates of the subsequent vertices of the polyline (or a compatible data object). If closed == True, the polyline is closed by connecting the last point to the first. This does not change the vertex data.
PolyLine objects have the following methods:
Return the vectors of the points to the next one.
The vectors are returned as a Coords object. If not closed, this returns one less vectors than the number of points.
Returns average directions at the inner nodes.
If open, the number of directions returned is 2 less than the number of points.
Returns the parameter values for relative curve lengths div.
div is a list of relative curve lengths (from 0.0 to 1.0). As a convenience, an single integer value may be specified, in which case the relative curve lengths are found by dividing the interval [0.0,1.0] in the specified number of subintervals.
The function returns a list with the parameter values for the points at the specified relative lengths.
A Polygon is a closed PolyLine.
Polygon objects have the following methods:
A class representing a Bezier spline curve.
Create a cubic spline curve through the given points.
The curve is defined by the points and the directions at these points. If no directions are specified, the average of the segments ending in that point is used, and in the end points of an open curve, the direction of the end segment. The curl parameter can be set to influence the curliness of the curve. curl=0.0 results in straight segments.
The control points can also be specified directly. If they are, they override the deriv and curl parameters. Since each segment of the curve needs two control points, the control array has shape (npts-1, 2, 3).
BezierSpline objects have the following methods:
A class representing a Bezier spline curve.
Create a cubic spline curve through the given points.
The curve is defined by the points and the directions at these points. If no directions are specified, the average of the segments ending in that point is used, and in the end points of an open curve, the direction of the end segment. The curl parameter can be set to influence the curliness of the curve. curl=0.0 results in straight segments. curl=1.0 The control points can also be specified directly. If they are, they override the deriv and curl parameters. Since each segment of the curve needs two control points, the control array has shape (npts-1, 2, 3).
QuadBezierSpline objects have the following methods:
A class representing a cardinal spline.
Create a natural spline through the given points.
The Cardinal Spline with given tension is a Bezier Spline with curl :math: curl = ( 1 - tension) / 3 The separate class name is retained for compatibility and convenience. See CardinalSpline2 for a direct implementation (it misses the end intervals of the point set).
Create a natural spline through the given points.
CardinalSpline objects have the following methods:
A class representing a cardinal spline.
Create a natural spline through the given points.
This is a direct implementation of the Cardinal Spline. For open curves, it misses the interpolation in the two end intervals of the point set. It is retained here because the implementation may some day replace the BezierSpline implementation.
CardinalSpline2 objects have the following methods:
A class representing a natural spline.
Create a natural spline through the given points.
coords specifies the coordinates of a set of points. A natural spline is constructed through this points. endcond specifies the end conditions in the first, resp. last point. It can be ‘notaknot’ or ‘secder’. With ‘notaknot’, maximal continuity (up to the third derivative) is obtained between the first two splines. With ‘secder’, the spline ends with a zero second derivative. If closed is True, the spline is closed, and endcond is ignored.
NaturalSpline objects have the following methods:
A class representing a circular arc.
Create a circular arc.
The arc is specified by 3 non-colinear points.
Arc3 objects have the following methods:
A class representing a circular arc.
Create a circular arc.
The arc is specified by the center and begin and end-point.
Arc objects have the following methods:
A class representing a spiral curve.
Spiral objects have the following methods:
Functions defined in the module curve
- curve.vectorPairAngle(v1, v2)¶
- Return the angle between the vectors v1 and v2.