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.
Classes defined in module curve
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 attributes and methods or override them if the defaults are not suitable.
Attributes:
Methods:
Furthermore it may define, for efficiency reasons, the following methods:
Return start and end points of the curve.
Returns a Coords with two points, or None if the curve is closed.
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.
Return the directions at values t in part j
t can be an array of parameter values, j is a single segment number.
Return the directions at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Split global parameter value in part number and local parameter
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.
Returns a tuple of arrays i,t, where i are the (integer) part numbers and t the local parameter values (between 0 and 1).
Return 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.
Returns a Coords with the coordinates of the points.
If normalized is True, the parameter values are give in a normalized space where 0 is the start of the curve and 1 is the end.
If return_position is True, also returns the part numbers on which the point are lying and the local parameter values.
Return the directions 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 sequence of points on the Curve.
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.
Split a curve into a list of partial curves
split is a list of integer values specifying the node numbers where the curve is to be split. As a convenience, a single int may be given if the curve is to be split at a single node, or None to split all all nodes.
Returns a list of open curves of the same type as the original.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
Return a PolyLine approximation of the curve
Parameters:
Returns a PolyLine approximation for the curve. C.approx(ndiv=n) returns an approximation with ndiv segments over each part of the curve. This may results in segments with very different lengths. C.approx(ntot=n) returns an approximation with ntot segments over the total length of the curve. This produces more equally sized segments, but the internal end points of the curve parts may not be on the approximating Polyline.
Return points and Frenet frame along the curve.
A PolyLine approximation for the curve is constructed, using the Curve.approx() method with the arguments ndiv and ntot. Then Frenet frames are constructed with PolyLine.movingFrenet() using the remaining arguments. The resulting PolyLine points and Frenet frames are returned.
Parameters:
upvector: (3,) vector: a vector normal to the (tangent,normal) plane at the first point of the curve. It defines the binormal at the first point. If not specified it is set to the shorted distance through the set of 10 first points.
avgdir: bool or array. If True (default), the tangential vector is set to the average direction of the two segments ending at a node. If False, the tangent vectors will be those of the line segment starting at the points. The tangential vector can also be set by the user by specifying an array with the matching number of vectors.
compensate: bool: If True, adds a compensation algorithm if the curve is closed. For a closed curve the moving Frenet algorithm can be continued back to the first point. If the resulting binormial does not coincide with the starting one, some torsion is added to the end portions of the curve to make the two binormals coincide.
This feature is off by default because it is currently experimental and is likely to change in future. It may also form the base for setting the starting as well as the ending binormal.
Returns:
Approximate a Curve with a PolyLine of n segments
Parameters:
Note
This is an alternative for Curve.approx, and may replace it in future.
Convert a curve to a Formex.
This creates a polyline approximation as a plex-2 Formex. This is mainly used for drawing curves that do not implement their own drawing routines.
The method can be passed the same arguments as the approx method.
Create or destroy the property array for the Formex.
A property array is a rank-1 integer array with dimension equal to the number of elements in the Formex (first dimension of data). You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.
If a value None is given, the properties are removed from the Formex.
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Return the number of elements in the Geometry.
This method should be re-implemented by the derived classes. For the (empty) Geometry class it always returns 0.
Converts the argument into a legal set of properties for the object.
The conversion involves resizing the argument to a 1D array of length self.nelems(), and converting the data type to integer.
Get the coords data.
Returns the full array of coordinates stored in the Geometry object. Note that subclasses may store more points in this array than are used to define the geometry.
Return the dimensionality of the Geometry, or -1 if unknown
Return a deep copy of the Geometry object.
The returned object is an exact copy of the input, but has all of its data independent of the former.
Partition a Geometry (Formex/Mesh) according to the values in prop.
Parameters:
Returns a list of Geometry objects of the same type as the input. Each object contains all the elements having the same value of prop. The number of objects in the list is equal to the number of unique values in prop. The list is sorted in ascending order of their prop value.
It prop is None and the the object has no prop attribute, an empty list is returned.
Return a copy of the Geometry scaled to the given size.
size can be a single value or a list of three values for the three coordinate directions. If it is a single value, all directions are scaled to the same size. Directions for which the geometry has a size smaller than tol times the maximum size are not rescaled.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
A class representing a series of straight line segments.
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.
The control parameter has the same meaning as coords and is added for symmetry with other Curve classes. If specified, it will override the coords argument.
Close a PolyLine.
If the PolyLine is already closed, it is returned unchanged. Else it is closed by adding a segment from the last to the first point (even if these are coincident).
Warning
This method changes the PolyLine inplace.
Open a closed PolyLine.
If the PolyLine is closed, it is opened by removing the last segment. Else, it is returned unchanged.
Warning
This method changes the PolyLine inplace.
Use split() if you want to open the PolyLine without losing a segment.
Return the polyline as a Formex.
Convert the polyLine to a plex-2 Mesh.
The returned Mesh is equivalent with the PolyLine.
Return the points at values t in part j
Return the points at value,part pairs (t,j)
Return the unit direction vectors at values t in part j.
Return the vectors of each point to the next one.
The vectors are returned as a Coords object. If the curve is not closed, the number of vectors returned is one less than the number of points.
Returns unit vectors in the direction of the next point.
This directions are returned as a Coords object with the same number of elements as the point set.
If two subsequent points are identical, the first one gets the direction of the previous segment. If more than two subsequent points are equal, an invalid direction (NaN) will result.
If the curve is not closed, the last direction is set equal to the penultimate.
If return_doubles is True, the return value is a tuple of the direction and an index of the points that are identical with their follower.
Returns the average directions at points.
For each point the returned direction is the average of the direction from the preceding point to the current, and the direction from the current to the next point.
If the curve is open, the first and last direction are equal to the direction of the first, resp. last segment.
Where two subsequent points are identical, the average directions are set equal to those of the segment ending in the first and the segment starting from the last.
Approximate a PolyLine with a PolyLine of n segments
Parameters:
Note
This is an alternative for Curve.approx, and may replace it in future.
Roll the points of a closed PolyLine.
Return the length of the parts of the curve.
Returns the parameter values at given relative curve length.
div is a list of relative curve lengths (from 0.0 to 1.0). As a convenience, a 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.
Return the same curve with the parameter direction reversed.
Return a PolyLine containing only segments j to k (k not included).
The resulting PolyLine is always open.
Return the parts of the polyline at one or both sides of a plane.
If side is ‘+’ or ‘-‘, return a list of PolyLines with the parts at the positive or negative side of the plane.
For any other value, returns a tuple of two lists of PolyLines, the first one being the parts at the positive side.
p is a point specified by 3 coordinates. n is the normal vector to a plane, specified by 3 components.
Append another PolyLine to this one.
Returns the concatenation of two open PolyLines. Closed PolyLines cannot be concatenated.
Insert new 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.
Returns a PolyLine with the new points inserted. Note that the parameter values of the points will have changed. If return_indices is True, also returns the indices of the inserted points in the new PolyLine.
Split a PolyLine at parametric 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.
Returns a list of open Polylines.
Return start and end points of the curve.
Returns a Coords with two points, or None if the curve is closed.
Return the directions at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Split global parameter value in part number and local parameter
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.
Returns a tuple of arrays i,t, where i are the (integer) part numbers and t the local parameter values (between 0 and 1).
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Return 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.
Returns a Coords with the coordinates of the points.
If normalized is True, the parameter values are give in a normalized space where 0 is the start of the curve and 1 is the end.
If return_position is True, also returns the part numbers on which the point are lying and the local parameter values.
Return the directions 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 sequence of points on the Curve.
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.
Converts the argument into a legal set of properties for the object.
The conversion involves resizing the argument to a 1D array of length self.nelems(), and converting the data type to integer.
Get the coords data.
Returns the full array of coordinates stored in the Geometry object. Note that subclasses may store more points in this array than are used to define the geometry.
Split a curve into a list of partial curves
split is a list of integer values specifying the node numbers where the curve is to be split. As a convenience, a single int may be given if the curve is to be split at a single node, or None to split all all nodes.
Returns a list of open curves of the same type as the original.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
Return a PolyLine approximation of the curve
Parameters:
Returns a PolyLine approximation for the curve. C.approx(ndiv=n) returns an approximation with ndiv segments over each part of the curve. This may results in segments with very different lengths. C.approx(ntot=n) returns an approximation with ntot segments over the total length of the curve. This produces more equally sized segments, but the internal end points of the curve parts may not be on the approximating Polyline.
Return the dimensionality of the Geometry, or -1 if unknown
Return points and Frenet frame along the curve.
A PolyLine approximation for the curve is constructed, using the Curve.approx() method with the arguments ndiv and ntot. Then Frenet frames are constructed with PolyLine.movingFrenet() using the remaining arguments. The resulting PolyLine points and Frenet frames are returned.
Parameters:
upvector: (3,) vector: a vector normal to the (tangent,normal) plane at the first point of the curve. It defines the binormal at the first point. If not specified it is set to the shorted distance through the set of 10 first points.
avgdir: bool or array. If True (default), the tangential vector is set to the average direction of the two segments ending at a node. If False, the tangent vectors will be those of the line segment starting at the points. The tangential vector can also be set by the user by specifying an array with the matching number of vectors.
compensate: bool: If True, adds a compensation algorithm if the curve is closed. For a closed curve the moving Frenet algorithm can be continued back to the first point. If the resulting binormial does not coincide with the starting one, some torsion is added to the end portions of the curve to make the two binormals coincide.
This feature is off by default because it is currently experimental and is likely to change in future. It may also form the base for setting the starting as well as the ending binormal.
Returns:
Return a deep copy of the Geometry object.
The returned object is an exact copy of the input, but has all of its data independent of the former.
Partition a Geometry (Formex/Mesh) according to the values in prop.
Parameters:
Returns a list of Geometry objects of the same type as the input. Each object contains all the elements having the same value of prop. The number of objects in the list is equal to the number of unique values in prop. The list is sorted in ascending order of their prop value.
It prop is None and the the object has no prop attribute, an empty list is returned.
Return a copy of the Geometry scaled to the given size.
size can be a single value or a list of three values for the three coordinate directions. If it is a single value, all directions are scaled to the same size. Directions for which the geometry has a size smaller than tol times the maximum size are not rescaled.
Create or destroy the property array for the Formex.
A property array is a rank-1 integer array with dimension equal to the number of elements in the Formex (first dimension of data). You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.
If a value None is given, the properties are removed from the Formex.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
A Line is a PolyLine with exactly two points.
Parameters:
Return start and end points of the curve.
Returns a Coords with two points, or None if the curve is closed.
Return the directions at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Split global parameter value in part number and local parameter
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.
Returns a tuple of arrays i,t, where i are the (integer) part numbers and t the local parameter values (between 0 and 1).
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Return 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.
Returns a Coords with the coordinates of the points.
If normalized is True, the parameter values are give in a normalized space where 0 is the start of the curve and 1 is the end.
If return_position is True, also returns the part numbers on which the point are lying and the local parameter values.
Return the directions 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 sequence of points on the Curve.
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.
Converts the argument into a legal set of properties for the object.
The conversion involves resizing the argument to a 1D array of length self.nelems(), and converting the data type to integer.
Get the coords data.
Returns the full array of coordinates stored in the Geometry object. Note that subclasses may store more points in this array than are used to define the geometry.
Split a curve into a list of partial curves
split is a list of integer values specifying the node numbers where the curve is to be split. As a convenience, a single int may be given if the curve is to be split at a single node, or None to split all all nodes.
Returns a list of open curves of the same type as the original.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
Return a PolyLine approximation of the curve
Parameters:
Returns a PolyLine approximation for the curve. C.approx(ndiv=n) returns an approximation with ndiv segments over each part of the curve. This may results in segments with very different lengths. C.approx(ntot=n) returns an approximation with ntot segments over the total length of the curve. This produces more equally sized segments, but the internal end points of the curve parts may not be on the approximating Polyline.
Return the dimensionality of the Geometry, or -1 if unknown
Return points and Frenet frame along the curve.
A PolyLine approximation for the curve is constructed, using the Curve.approx() method with the arguments ndiv and ntot. Then Frenet frames are constructed with PolyLine.movingFrenet() using the remaining arguments. The resulting PolyLine points and Frenet frames are returned.
Parameters:
upvector: (3,) vector: a vector normal to the (tangent,normal) plane at the first point of the curve. It defines the binormal at the first point. If not specified it is set to the shorted distance through the set of 10 first points.
avgdir: bool or array. If True (default), the tangential vector is set to the average direction of the two segments ending at a node. If False, the tangent vectors will be those of the line segment starting at the points. The tangential vector can also be set by the user by specifying an array with the matching number of vectors.
compensate: bool: If True, adds a compensation algorithm if the curve is closed. For a closed curve the moving Frenet algorithm can be continued back to the first point. If the resulting binormial does not coincide with the starting one, some torsion is added to the end portions of the curve to make the two binormals coincide.
This feature is off by default because it is currently experimental and is likely to change in future. It may also form the base for setting the starting as well as the ending binormal.
Returns:
Return a deep copy of the Geometry object.
The returned object is an exact copy of the input, but has all of its data independent of the former.
Partition a Geometry (Formex/Mesh) according to the values in prop.
Parameters:
Returns a list of Geometry objects of the same type as the input. Each object contains all the elements having the same value of prop. The number of objects in the list is equal to the number of unique values in prop. The list is sorted in ascending order of their prop value.
It prop is None and the the object has no prop attribute, an empty list is returned.
Return a copy of the Geometry scaled to the given size.
size can be a single value or a list of three values for the three coordinate directions. If it is a single value, all directions are scaled to the same size. Directions for which the geometry has a size smaller than tol times the maximum size are not rescaled.
Create or destroy the property array for the Formex.
A property array is a rank-1 integer array with dimension equal to the number of elements in the Formex (first dimension of data). You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.
If a value None is given, the properties are removed from the Formex.
Close a PolyLine.
If the PolyLine is already closed, it is returned unchanged. Else it is closed by adding a segment from the last to the first point (even if these are coincident).
Warning
This method changes the PolyLine inplace.
Open a closed PolyLine.
If the PolyLine is closed, it is opened by removing the last segment. Else, it is returned unchanged.
Warning
This method changes the PolyLine inplace.
Use split() if you want to open the PolyLine without losing a segment.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
Return the polyline as a Formex.
Convert the polyLine to a plex-2 Mesh.
The returned Mesh is equivalent with the PolyLine.
Return the points at values t in part j
Return the points at value,part pairs (t,j)
Return the unit direction vectors at values t in part j.
Return the vectors of each point to the next one.
The vectors are returned as a Coords object. If the curve is not closed, the number of vectors returned is one less than the number of points.
Returns unit vectors in the direction of the next point.
This directions are returned as a Coords object with the same number of elements as the point set.
If two subsequent points are identical, the first one gets the direction of the previous segment. If more than two subsequent points are equal, an invalid direction (NaN) will result.
If the curve is not closed, the last direction is set equal to the penultimate.
If return_doubles is True, the return value is a tuple of the direction and an index of the points that are identical with their follower.
Returns the average directions at points.
For each point the returned direction is the average of the direction from the preceding point to the current, and the direction from the current to the next point.
If the curve is open, the first and last direction are equal to the direction of the first, resp. last segment.
Where two subsequent points are identical, the average directions are set equal to those of the segment ending in the first and the segment starting from the last.
Approximate a PolyLine with a PolyLine of n segments
Parameters:
Note
This is an alternative for Curve.approx, and may replace it in future.
Roll the points of a closed PolyLine.
Return the length of the parts of the curve.
Returns the parameter values at given relative curve length.
div is a list of relative curve lengths (from 0.0 to 1.0). As a convenience, a 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.
Return the same curve with the parameter direction reversed.
Return a PolyLine containing only segments j to k (k not included).
The resulting PolyLine is always open.
Return the parts of the polyline at one or both sides of a plane.
If side is ‘+’ or ‘-‘, return a list of PolyLines with the parts at the positive or negative side of the plane.
For any other value, returns a tuple of two lists of PolyLines, the first one being the parts at the positive side.
p is a point specified by 3 coordinates. n is the normal vector to a plane, specified by 3 components.
Append another PolyLine to this one.
Returns the concatenation of two open PolyLines. Closed PolyLines cannot be concatenated.
Insert new 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.
Returns a PolyLine with the new points inserted. Note that the parameter values of the points will have changed. If return_indices is True, also returns the indices of the inserted points in the new PolyLine.
Split a PolyLine at parametric 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.
Returns a list of open Polylines.
A class representing a Bezier spline curve of degree 1, 2 or 3.
A Bezier spline of degree d is a continuous curve consisting of nparts successive parts, where each part is a Bezier curve of the same degree. Currently pyFormex can model linear, quadratic and cubic BezierSplines. A linear BezierSpline is equivalent to a PolyLine, which has more specialized methods than the BezierSpline, so it might be more sensible to use a PolyLine instead of the linear BezierSpline.
A Bezier curve of degree d is determined by d+1 control points, of which the first and the last are on the curve, while the intermediate d-1 points are not. Since the end point of one part is the begin point of the next part, a BezierSpline is described by ncontrol=d*nparts+1 control points if the curve is open, or ncontrol=d*nparts if the curve is closed.
The constructor provides different ways to initialize the full set of control points. In many cases the off-curve control points can be generated automatically.
Parameters:
coords : array_like (npoints,3) The points that are on the curve. For an open curve, npoints=nparts+1, for a closed curve, npoints = nparts. If not specified, the on-curve points should be included in the control argument.
deriv : array_like (npoints,3) or (2,3) or a list of 2 values one of which can be None and the other is a shape(3,) arraylike. If specified, it gives the direction of the curve at all points or at the endpoints only for a shape (2,3) array or only at one of the endpoints for a list of shape(3,) arraylike and a None type. For points where the direction is left unspecified or where the specified direction contains a NaN value, the direction is calculated as the average direction of the two line segments ending in the point. This will also be used for points where the specified direction contains a value NaN. In the two endpoints of an open curve however, this average direction can not be calculated: the two control points in these parts are set coincident.
curl : float The curl parameter can be set to influence the curliness of the curve in between two subsequent points. A value curl=0.0 results in straight segments. The higher the value, the more the curve becomes curled.
control : array(nparts,2,3) or array(ncontrol,3) If coords was specified, this should be a (nparts,2,3) array with the intermediate control points, two for each part.
If coords was not specified, this should be the full array of ncontrol control points for the curve. The number of points should be a multiple of 3 plus 1. If the curve is closed, the last point is equal to the first and does not need to a multiple of 3 is also allowed, in which case the first point will be appended as last.
If not specified, the control points are generated automatically from the coords, deriv and curl arguments. If specified, they override these parameters.
closed : boolean If True, the curve will be continued from the last point back to the first to create a closed curve.
degree: int (1, 2 or 3) Specfies the degree of the curve. Default is 3.
endzerocurv : boolean or tuple of two booleans. Specifies the end conditions for an open curve. If True, the end curvature will be forced to zero. The default is to use maximal continuity of the curvature. The value may be set to a tuple of two values to specify different conditions for both ends. This argument is ignored for a closed curve.
Return the points on the curve.
This returns a Coords object of shape [nparts+1]. For a closed curve, the last point will be equal to the first.
Return the points off the curve (the control points)
This returns a Coords object of shape [nparts,ndegree-1], or an empty Coords if degree <= 1.
Returns the points defining part j of the curve.
Return the points at values t in part j.
Return the unit direction vectors at values t in part j.
Return the curvature at values t in part j.
Return the arc length integrand at value t in part j.
Return the length of the parts of the curve.
Return a curve containing only parts j to k (k not included).
The resulting curve is always open.
Convert the BezierSpline to a Mesh.
For degrees 1 or 2, the returned Mesh is equivalent with the BezierSpline, and will have element type ‘line1’, resp. ‘line2’.
For degree 3, the returned Mesh will currently be a quadratic approximation with element type ‘line2’.
Return a PolyLine approximation of the curve.
tol is a tolerance value for the flatness of the curve. The flatness of each part is calculated as the maximum orthogonal distance of its intermediate control points from the straight segment through its end points.
Parts for which the distance is larger than tol are subdivided using de Casteljau’s algorithm. The subdivision stops if all parts are sufficiently flat. The return value is a PolyLine connecting the end points of all parts.
Extend the curve beyond its endpoints.
This function will add a Bezier curve before the first part and/or after the last part by applying de Casteljau’s algorithm on this part.
Return the same curve with the parameter direction reversed.
Return start and end points of the curve.
Returns a Coords with two points, or None if the curve is closed.
Return the points at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Return the directions at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Split global parameter value in part number and local parameter
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.
Returns a tuple of arrays i,t, where i are the (integer) part numbers and t the local parameter values (between 0 and 1).
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Return 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.
Returns a Coords with the coordinates of the points.
If normalized is True, the parameter values are give in a normalized space where 0 is the start of the curve and 1 is the end.
If return_position is True, also returns the part numbers on which the point are lying and the local parameter values.
Return the number of elements in the Geometry.
This method should be re-implemented by the derived classes. For the (empty) Geometry class it always returns 0.
Return the directions 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 sequence of points on the Curve.
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.
Converts the argument into a legal set of properties for the object.
The conversion involves resizing the argument to a 1D array of length self.nelems(), and converting the data type to integer.
Get the coords data.
Returns the full array of coordinates stored in the Geometry object. Note that subclasses may store more points in this array than are used to define the geometry.
Split a curve into a list of partial curves
split is a list of integer values specifying the node numbers where the curve is to be split. As a convenience, a single int may be given if the curve is to be split at a single node, or None to split all all nodes.
Returns a list of open curves of the same type as the original.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
Return a PolyLine approximation of the curve
Parameters:
Returns a PolyLine approximation for the curve. C.approx(ndiv=n) returns an approximation with ndiv segments over each part of the curve. This may results in segments with very different lengths. C.approx(ntot=n) returns an approximation with ntot segments over the total length of the curve. This produces more equally sized segments, but the internal end points of the curve parts may not be on the approximating Polyline.
Return the dimensionality of the Geometry, or -1 if unknown
Return points and Frenet frame along the curve.
A PolyLine approximation for the curve is constructed, using the Curve.approx() method with the arguments ndiv and ntot. Then Frenet frames are constructed with PolyLine.movingFrenet() using the remaining arguments. The resulting PolyLine points and Frenet frames are returned.
Parameters:
upvector: (3,) vector: a vector normal to the (tangent,normal) plane at the first point of the curve. It defines the binormal at the first point. If not specified it is set to the shorted distance through the set of 10 first points.
avgdir: bool or array. If True (default), the tangential vector is set to the average direction of the two segments ending at a node. If False, the tangent vectors will be those of the line segment starting at the points. The tangential vector can also be set by the user by specifying an array with the matching number of vectors.
compensate: bool: If True, adds a compensation algorithm if the curve is closed. For a closed curve the moving Frenet algorithm can be continued back to the first point. If the resulting binormial does not coincide with the starting one, some torsion is added to the end portions of the curve to make the two binormals coincide.
This feature is off by default because it is currently experimental and is likely to change in future. It may also form the base for setting the starting as well as the ending binormal.
Returns:
Return a deep copy of the Geometry object.
The returned object is an exact copy of the input, but has all of its data independent of the former.
Partition a Geometry (Formex/Mesh) according to the values in prop.
Parameters:
Returns a list of Geometry objects of the same type as the input. Each object contains all the elements having the same value of prop. The number of objects in the list is equal to the number of unique values in prop. The list is sorted in ascending order of their prop value.
It prop is None and the the object has no prop attribute, an empty list is returned.
Return a copy of the Geometry scaled to the given size.
size can be a single value or a list of three values for the three coordinate directions. If it is a single value, all directions are scaled to the same size. Directions for which the geometry has a size smaller than tol times the maximum size are not rescaled.
Approximate a Curve with a PolyLine of n segments
Parameters:
Note
This is an alternative for Curve.approx, and may replace it in future.
Convert a curve to a Formex.
This creates a polyline approximation as a plex-2 Formex. This is mainly used for drawing curves that do not implement their own drawing routines.
The method can be passed the same arguments as the approx method.
Create or destroy the property array for the Formex.
A property array is a rank-1 integer array with dimension equal to the number of elements in the Formex (first dimension of data). You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.
If a value None is given, the properties are removed from the Formex.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
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).
Return start and end points of the curve.
Returns a Coords with two points, or None if the curve is closed.
Return the points at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Return the directions at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Split global parameter value in part number and local parameter
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.
Returns a tuple of arrays i,t, where i are the (integer) part numbers and t the local parameter values (between 0 and 1).
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Return 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.
Returns a Coords with the coordinates of the points.
If normalized is True, the parameter values are give in a normalized space where 0 is the start of the curve and 1 is the end.
If return_position is True, also returns the part numbers on which the point are lying and the local parameter values.
Return the number of elements in the Geometry.
This method should be re-implemented by the derived classes. For the (empty) Geometry class it always returns 0.
Return the directions 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 sequence of points on the Curve.
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.
Converts the argument into a legal set of properties for the object.
The conversion involves resizing the argument to a 1D array of length self.nelems(), and converting the data type to integer.
Get the coords data.
Returns the full array of coordinates stored in the Geometry object. Note that subclasses may store more points in this array than are used to define the geometry.
Split a curve into a list of partial curves
split is a list of integer values specifying the node numbers where the curve is to be split. As a convenience, a single int may be given if the curve is to be split at a single node, or None to split all all nodes.
Returns a list of open curves of the same type as the original.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
Return a PolyLine approximation of the curve
Parameters:
Returns a PolyLine approximation for the curve. C.approx(ndiv=n) returns an approximation with ndiv segments over each part of the curve. This may results in segments with very different lengths. C.approx(ntot=n) returns an approximation with ntot segments over the total length of the curve. This produces more equally sized segments, but the internal end points of the curve parts may not be on the approximating Polyline.
Return the dimensionality of the Geometry, or -1 if unknown
Return points and Frenet frame along the curve.
A PolyLine approximation for the curve is constructed, using the Curve.approx() method with the arguments ndiv and ntot. Then Frenet frames are constructed with PolyLine.movingFrenet() using the remaining arguments. The resulting PolyLine points and Frenet frames are returned.
Parameters:
upvector: (3,) vector: a vector normal to the (tangent,normal) plane at the first point of the curve. It defines the binormal at the first point. If not specified it is set to the shorted distance through the set of 10 first points.
avgdir: bool or array. If True (default), the tangential vector is set to the average direction of the two segments ending at a node. If False, the tangent vectors will be those of the line segment starting at the points. The tangential vector can also be set by the user by specifying an array with the matching number of vectors.
compensate: bool: If True, adds a compensation algorithm if the curve is closed. For a closed curve the moving Frenet algorithm can be continued back to the first point. If the resulting binormial does not coincide with the starting one, some torsion is added to the end portions of the curve to make the two binormals coincide.
This feature is off by default because it is currently experimental and is likely to change in future. It may also form the base for setting the starting as well as the ending binormal.
Returns:
Return a deep copy of the Geometry object.
The returned object is an exact copy of the input, but has all of its data independent of the former.
Partition a Geometry (Formex/Mesh) according to the values in prop.
Parameters:
Returns a list of Geometry objects of the same type as the input. Each object contains all the elements having the same value of prop. The number of objects in the list is equal to the number of unique values in prop. The list is sorted in ascending order of their prop value.
It prop is None and the the object has no prop attribute, an empty list is returned.
Return a copy of the Geometry scaled to the given size.
size can be a single value or a list of three values for the three coordinate directions. If it is a single value, all directions are scaled to the same size. Directions for which the geometry has a size smaller than tol times the maximum size are not rescaled.
Approximate a Curve with a PolyLine of n segments
Parameters:
Note
This is an alternative for Curve.approx, and may replace it in future.
Convert a curve to a Formex.
This creates a polyline approximation as a plex-2 Formex. This is mainly used for drawing curves that do not implement their own drawing routines.
The method can be passed the same arguments as the approx method.
Create or destroy the property array for the Formex.
A property array is a rank-1 integer array with dimension equal to the number of elements in the Formex (first dimension of data). You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.
If a value None is given, the properties are removed from the Formex.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
Return the points on the curve.
This returns a Coords object of shape [nparts+1]. For a closed curve, the last point will be equal to the first.
Return the points off the curve (the control points)
This returns a Coords object of shape [nparts,ndegree-1], or an empty Coords if degree <= 1.
Returns the points defining part j of the curve.
Return the points at values t in part j.
Return the unit direction vectors at values t in part j.
Return the curvature at values t in part j.
Return the arc length integrand at value t in part j.
Return the length of the parts of the curve.
Return a curve containing only parts j to k (k not included).
The resulting curve is always open.
Convert the BezierSpline to a Mesh.
For degrees 1 or 2, the returned Mesh is equivalent with the BezierSpline, and will have element type ‘line1’, resp. ‘line2’.
For degree 3, the returned Mesh will currently be a quadratic approximation with element type ‘line2’.
Return a PolyLine approximation of the curve.
tol is a tolerance value for the flatness of the curve. The flatness of each part is calculated as the maximum orthogonal distance of its intermediate control points from the straight segment through its end points.
Parts for which the distance is larger than tol are subdivided using de Casteljau’s algorithm. The subdivision stops if all parts are sufficiently flat. The return value is a PolyLine connecting the end points of all parts.
Extend the curve beyond its endpoints.
This function will add a Bezier curve before the first part and/or after the last part by applying de Casteljau’s algorithm on this part.
Return the same curve with the parameter direction reversed.
A class representing a cardinal spline.
Return start and end points of the curve.
Returns a Coords with two points, or None if the curve is closed.
Return the points at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Return the directions at values t in part j
t can be an array of parameter values, j is a single segment number.
Return the directions at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Split global parameter value in part number and local parameter
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.
Returns a tuple of arrays i,t, where i are the (integer) part numbers and t the local parameter values (between 0 and 1).
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Return 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.
Returns a Coords with the coordinates of the points.
If normalized is True, the parameter values are give in a normalized space where 0 is the start of the curve and 1 is the end.
If return_position is True, also returns the part numbers on which the point are lying and the local parameter values.
Return the number of elements in the Geometry.
This method should be re-implemented by the derived classes. For the (empty) Geometry class it always returns 0.
Return the directions 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 sequence of points on the Curve.
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.
Converts the argument into a legal set of properties for the object.
The conversion involves resizing the argument to a 1D array of length self.nelems(), and converting the data type to integer.
Get the coords data.
Returns the full array of coordinates stored in the Geometry object. Note that subclasses may store more points in this array than are used to define the geometry.
Split a curve into a list of partial curves
split is a list of integer values specifying the node numbers where the curve is to be split. As a convenience, a single int may be given if the curve is to be split at a single node, or None to split all all nodes.
Returns a list of open curves of the same type as the original.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
Return a PolyLine approximation of the curve
Parameters:
Returns a PolyLine approximation for the curve. C.approx(ndiv=n) returns an approximation with ndiv segments over each part of the curve. This may results in segments with very different lengths. C.approx(ntot=n) returns an approximation with ntot segments over the total length of the curve. This produces more equally sized segments, but the internal end points of the curve parts may not be on the approximating Polyline.
Return the dimensionality of the Geometry, or -1 if unknown
Return points and Frenet frame along the curve.
A PolyLine approximation for the curve is constructed, using the Curve.approx() method with the arguments ndiv and ntot. Then Frenet frames are constructed with PolyLine.movingFrenet() using the remaining arguments. The resulting PolyLine points and Frenet frames are returned.
Parameters:
upvector: (3,) vector: a vector normal to the (tangent,normal) plane at the first point of the curve. It defines the binormal at the first point. If not specified it is set to the shorted distance through the set of 10 first points.
avgdir: bool or array. If True (default), the tangential vector is set to the average direction of the two segments ending at a node. If False, the tangent vectors will be those of the line segment starting at the points. The tangential vector can also be set by the user by specifying an array with the matching number of vectors.
compensate: bool: If True, adds a compensation algorithm if the curve is closed. For a closed curve the moving Frenet algorithm can be continued back to the first point. If the resulting binormial does not coincide with the starting one, some torsion is added to the end portions of the curve to make the two binormals coincide.
This feature is off by default because it is currently experimental and is likely to change in future. It may also form the base for setting the starting as well as the ending binormal.
Returns:
Return a deep copy of the Geometry object.
The returned object is an exact copy of the input, but has all of its data independent of the former.
Partition a Geometry (Formex/Mesh) according to the values in prop.
Parameters:
Returns a list of Geometry objects of the same type as the input. Each object contains all the elements having the same value of prop. The number of objects in the list is equal to the number of unique values in prop. The list is sorted in ascending order of their prop value.
It prop is None and the the object has no prop attribute, an empty list is returned.
Return a copy of the Geometry scaled to the given size.
size can be a single value or a list of three values for the three coordinate directions. If it is a single value, all directions are scaled to the same size. Directions for which the geometry has a size smaller than tol times the maximum size are not rescaled.
Approximate a Curve with a PolyLine of n segments
Parameters:
Note
This is an alternative for Curve.approx, and may replace it in future.
Convert a curve to a Formex.
This creates a polyline approximation as a plex-2 Formex. This is mainly used for drawing curves that do not implement their own drawing routines.
The method can be passed the same arguments as the approx method.
Create or destroy the property array for the Formex.
A property array is a rank-1 integer array with dimension equal to the number of elements in the Formex (first dimension of data). You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.
If a value None is given, the properties are removed from the Formex.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
A class representing a natural spline.
Return start and end points of the curve.
Returns a Coords with two points, or None if the curve is closed.
Return the points at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Return the directions at values t in part j
t can be an array of parameter values, j is a single segment number.
Return the directions at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Split global parameter value in part number and local parameter
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.
Returns a tuple of arrays i,t, where i are the (integer) part numbers and t the local parameter values (between 0 and 1).
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Return 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.
Returns a Coords with the coordinates of the points.
If normalized is True, the parameter values are give in a normalized space where 0 is the start of the curve and 1 is the end.
If return_position is True, also returns the part numbers on which the point are lying and the local parameter values.
Return the number of elements in the Geometry.
This method should be re-implemented by the derived classes. For the (empty) Geometry class it always returns 0.
Return the directions 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 sequence of points on the Curve.
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.
Converts the argument into a legal set of properties for the object.
The conversion involves resizing the argument to a 1D array of length self.nelems(), and converting the data type to integer.
Get the coords data.
Returns the full array of coordinates stored in the Geometry object. Note that subclasses may store more points in this array than are used to define the geometry.
Split a curve into a list of partial curves
split is a list of integer values specifying the node numbers where the curve is to be split. As a convenience, a single int may be given if the curve is to be split at a single node, or None to split all all nodes.
Returns a list of open curves of the same type as the original.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
Return a PolyLine approximation of the curve
Parameters:
Returns a PolyLine approximation for the curve. C.approx(ndiv=n) returns an approximation with ndiv segments over each part of the curve. This may results in segments with very different lengths. C.approx(ntot=n) returns an approximation with ntot segments over the total length of the curve. This produces more equally sized segments, but the internal end points of the curve parts may not be on the approximating Polyline.
Return the dimensionality of the Geometry, or -1 if unknown
Return points and Frenet frame along the curve.
A PolyLine approximation for the curve is constructed, using the Curve.approx() method with the arguments ndiv and ntot. Then Frenet frames are constructed with PolyLine.movingFrenet() using the remaining arguments. The resulting PolyLine points and Frenet frames are returned.
Parameters:
upvector: (3,) vector: a vector normal to the (tangent,normal) plane at the first point of the curve. It defines the binormal at the first point. If not specified it is set to the shorted distance through the set of 10 first points.
avgdir: bool or array. If True (default), the tangential vector is set to the average direction of the two segments ending at a node. If False, the tangent vectors will be those of the line segment starting at the points. The tangential vector can also be set by the user by specifying an array with the matching number of vectors.
compensate: bool: If True, adds a compensation algorithm if the curve is closed. For a closed curve the moving Frenet algorithm can be continued back to the first point. If the resulting binormial does not coincide with the starting one, some torsion is added to the end portions of the curve to make the two binormals coincide.
This feature is off by default because it is currently experimental and is likely to change in future. It may also form the base for setting the starting as well as the ending binormal.
Returns:
Return a deep copy of the Geometry object.
The returned object is an exact copy of the input, but has all of its data independent of the former.
Partition a Geometry (Formex/Mesh) according to the values in prop.
Parameters:
Returns a list of Geometry objects of the same type as the input. Each object contains all the elements having the same value of prop. The number of objects in the list is equal to the number of unique values in prop. The list is sorted in ascending order of their prop value.
It prop is None and the the object has no prop attribute, an empty list is returned.
Return a copy of the Geometry scaled to the given size.
size can be a single value or a list of three values for the three coordinate directions. If it is a single value, all directions are scaled to the same size. Directions for which the geometry has a size smaller than tol times the maximum size are not rescaled.
Approximate a Curve with a PolyLine of n segments
Parameters:
Note
This is an alternative for Curve.approx, and may replace it in future.
Convert a curve to a Formex.
This creates a polyline approximation as a plex-2 Formex. This is mainly used for drawing curves that do not implement their own drawing routines.
The method can be passed the same arguments as the approx method.
Create or destroy the property array for the Formex.
A property array is a rank-1 integer array with dimension equal to the number of elements in the Formex (first dimension of data). You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.
If a value None is given, the properties are removed from the Formex.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
A class representing a circular arc.
Return start and end points of the curve.
Returns a Coords with two points, or None if the curve is closed.
Return the points at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Return the directions at values t in part j
t can be an array of parameter values, j is a single segment number.
Return the directions at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Split global parameter value in part number and local parameter
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.
Returns a tuple of arrays i,t, where i are the (integer) part numbers and t the local parameter values (between 0 and 1).
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Return 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.
Returns a Coords with the coordinates of the points.
If normalized is True, the parameter values are give in a normalized space where 0 is the start of the curve and 1 is the end.
If return_position is True, also returns the part numbers on which the point are lying and the local parameter values.
Return the number of elements in the Geometry.
This method should be re-implemented by the derived classes. For the (empty) Geometry class it always returns 0.
Return the directions 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 sequence of points on the Curve.
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.
Converts the argument into a legal set of properties for the object.
The conversion involves resizing the argument to a 1D array of length self.nelems(), and converting the data type to integer.
Get the coords data.
Returns the full array of coordinates stored in the Geometry object. Note that subclasses may store more points in this array than are used to define the geometry.
Split a curve into a list of partial curves
split is a list of integer values specifying the node numbers where the curve is to be split. As a convenience, a single int may be given if the curve is to be split at a single node, or None to split all all nodes.
Returns a list of open curves of the same type as the original.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
Return a PolyLine approximation of the curve
Parameters:
Returns a PolyLine approximation for the curve. C.approx(ndiv=n) returns an approximation with ndiv segments over each part of the curve. This may results in segments with very different lengths. C.approx(ntot=n) returns an approximation with ntot segments over the total length of the curve. This produces more equally sized segments, but the internal end points of the curve parts may not be on the approximating Polyline.
Return the dimensionality of the Geometry, or -1 if unknown
Return points and Frenet frame along the curve.
A PolyLine approximation for the curve is constructed, using the Curve.approx() method with the arguments ndiv and ntot. Then Frenet frames are constructed with PolyLine.movingFrenet() using the remaining arguments. The resulting PolyLine points and Frenet frames are returned.
Parameters:
upvector: (3,) vector: a vector normal to the (tangent,normal) plane at the first point of the curve. It defines the binormal at the first point. If not specified it is set to the shorted distance through the set of 10 first points.
avgdir: bool or array. If True (default), the tangential vector is set to the average direction of the two segments ending at a node. If False, the tangent vectors will be those of the line segment starting at the points. The tangential vector can also be set by the user by specifying an array with the matching number of vectors.
compensate: bool: If True, adds a compensation algorithm if the curve is closed. For a closed curve the moving Frenet algorithm can be continued back to the first point. If the resulting binormial does not coincide with the starting one, some torsion is added to the end portions of the curve to make the two binormals coincide.
This feature is off by default because it is currently experimental and is likely to change in future. It may also form the base for setting the starting as well as the ending binormal.
Returns:
Return a deep copy of the Geometry object.
The returned object is an exact copy of the input, but has all of its data independent of the former.
Partition a Geometry (Formex/Mesh) according to the values in prop.
Parameters:
Returns a list of Geometry objects of the same type as the input. Each object contains all the elements having the same value of prop. The number of objects in the list is equal to the number of unique values in prop. The list is sorted in ascending order of their prop value.
It prop is None and the the object has no prop attribute, an empty list is returned.
Return a copy of the Geometry scaled to the given size.
size can be a single value or a list of three values for the three coordinate directions. If it is a single value, all directions are scaled to the same size. Directions for which the geometry has a size smaller than tol times the maximum size are not rescaled.
Approximate a Curve with a PolyLine of n segments
Parameters:
Note
This is an alternative for Curve.approx, and may replace it in future.
Convert a curve to a Formex.
This creates a polyline approximation as a plex-2 Formex. This is mainly used for drawing curves that do not implement their own drawing routines.
The method can be passed the same arguments as the approx method.
Create or destroy the property array for the Formex.
A property array is a rank-1 integer array with dimension equal to the number of elements in the Formex (first dimension of data). You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.
If a value None is given, the properties are removed from the Formex.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
A class representing a circular arc.
The arc can be specified by 3 points (begin, center, end) or by center, radius and two angles. In the latter case, the arc lies in a plane parallel to the x,y plane. If specified by 3 colinear points, the plane of the circle will be parallel to the x,y plane if the points are in such plane, else the plane will be parallel to the z-axis.
Return start and end points of the curve.
Returns a Coords with two points, or None if the curve is closed.
Return the points at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Return the directions at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Split global parameter value in part number and local parameter
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.
Returns a tuple of arrays i,t, where i are the (integer) part numbers and t the local parameter values (between 0 and 1).
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Return 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.
Returns a Coords with the coordinates of the points.
If normalized is True, the parameter values are give in a normalized space where 0 is the start of the curve and 1 is the end.
If return_position is True, also returns the part numbers on which the point are lying and the local parameter values.
Return the number of elements in the Geometry.
This method should be re-implemented by the derived classes. For the (empty) Geometry class it always returns 0.
Return the directions 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 sequence of points on the Curve.
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.
Converts the argument into a legal set of properties for the object.
The conversion involves resizing the argument to a 1D array of length self.nelems(), and converting the data type to integer.
Get the coords data.
Returns the full array of coordinates stored in the Geometry object. Note that subclasses may store more points in this array than are used to define the geometry.
Split a curve into a list of partial curves
split is a list of integer values specifying the node numbers where the curve is to be split. As a convenience, a single int may be given if the curve is to be split at a single node, or None to split all all nodes.
Returns a list of open curves of the same type as the original.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
Return the dimensionality of the Geometry, or -1 if unknown
Return points and Frenet frame along the curve.
A PolyLine approximation for the curve is constructed, using the Curve.approx() method with the arguments ndiv and ntot. Then Frenet frames are constructed with PolyLine.movingFrenet() using the remaining arguments. The resulting PolyLine points and Frenet frames are returned.
Parameters:
upvector: (3,) vector: a vector normal to the (tangent,normal) plane at the first point of the curve. It defines the binormal at the first point. If not specified it is set to the shorted distance through the set of 10 first points.
avgdir: bool or array. If True (default), the tangential vector is set to the average direction of the two segments ending at a node. If False, the tangent vectors will be those of the line segment starting at the points. The tangential vector can also be set by the user by specifying an array with the matching number of vectors.
compensate: bool: If True, adds a compensation algorithm if the curve is closed. For a closed curve the moving Frenet algorithm can be continued back to the first point. If the resulting binormial does not coincide with the starting one, some torsion is added to the end portions of the curve to make the two binormals coincide.
This feature is off by default because it is currently experimental and is likely to change in future. It may also form the base for setting the starting as well as the ending binormal.
Returns:
Return a deep copy of the Geometry object.
The returned object is an exact copy of the input, but has all of its data independent of the former.
Partition a Geometry (Formex/Mesh) according to the values in prop.
Parameters:
Returns a list of Geometry objects of the same type as the input. Each object contains all the elements having the same value of prop. The number of objects in the list is equal to the number of unique values in prop. The list is sorted in ascending order of their prop value.
It prop is None and the the object has no prop attribute, an empty list is returned.
Return a copy of the Geometry scaled to the given size.
size can be a single value or a list of three values for the three coordinate directions. If it is a single value, all directions are scaled to the same size. Directions for which the geometry has a size smaller than tol times the maximum size are not rescaled.
Approximate a Curve with a PolyLine of n segments
Parameters:
Note
This is an alternative for Curve.approx, and may replace it in future.
Convert a curve to a Formex.
This creates a polyline approximation as a plex-2 Formex. This is mainly used for drawing curves that do not implement their own drawing routines.
The method can be passed the same arguments as the approx method.
Create or destroy the property array for the Formex.
A property array is a rank-1 integer array with dimension equal to the number of elements in the Formex (first dimension of data). You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.
If a value None is given, the properties are removed from the Formex.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
Return a PolyLine approximation of the Arc.
Approximates the Arc by a sequence of inscribed straight line segments.
If ndiv is specified, the arc is divided in pecisely ndiv segments.
If ndiv is not given, the number of segments is determined from the chordal distance tolerance. It will guarantee that the distance of any point of the arc to the chordal approximation is less or equal than chordal times the radius of the arc.
A class representing a spiral curve.
Return start and end points of the curve.
Returns a Coords with two points, or None if the curve is closed.
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.
Return the directions at values t in part j
t can be an array of parameter values, j is a single segment number.
Return the directions at values,parts given by zip(t,j)
t and j can both be arrays, but should have the same length.
Split global parameter value in part number and local parameter
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.
Returns a tuple of arrays i,t, where i are the (integer) part numbers and t the local parameter values (between 0 and 1).
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Return 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.
Returns a Coords with the coordinates of the points.
If normalized is True, the parameter values are give in a normalized space where 0 is the start of the curve and 1 is the end.
If return_position is True, also returns the part numbers on which the point are lying and the local parameter values.
Return the number of elements in the Geometry.
This method should be re-implemented by the derived classes. For the (empty) Geometry class it always returns 0.
Return the directions 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 sequence of points on the Curve.
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.
Converts the argument into a legal set of properties for the object.
The conversion involves resizing the argument to a 1D array of length self.nelems(), and converting the data type to integer.
Get the coords data.
Returns the full array of coordinates stored in the Geometry object. Note that subclasses may store more points in this array than are used to define the geometry.
Split a curve into a list of partial curves
split is a list of integer values specifying the node numbers where the curve is to be split. As a convenience, a single int may be given if the curve is to be split at a single node, or None to split all all nodes.
Returns a list of open curves of the same type as the original.
Return the total length of the curve.
This is only available for curves that implement the ‘lengths’ method.
Return a PolyLine approximation of the curve
Parameters:
Returns a PolyLine approximation for the curve. C.approx(ndiv=n) returns an approximation with ndiv segments over each part of the curve. This may results in segments with very different lengths. C.approx(ntot=n) returns an approximation with ntot segments over the total length of the curve. This produces more equally sized segments, but the internal end points of the curve parts may not be on the approximating Polyline.
Return the dimensionality of the Geometry, or -1 if unknown
Return points and Frenet frame along the curve.
A PolyLine approximation for the curve is constructed, using the Curve.approx() method with the arguments ndiv and ntot. Then Frenet frames are constructed with PolyLine.movingFrenet() using the remaining arguments. The resulting PolyLine points and Frenet frames are returned.
Parameters:
upvector: (3,) vector: a vector normal to the (tangent,normal) plane at the first point of the curve. It defines the binormal at the first point. If not specified it is set to the shorted distance through the set of 10 first points.
avgdir: bool or array. If True (default), the tangential vector is set to the average direction of the two segments ending at a node. If False, the tangent vectors will be those of the line segment starting at the points. The tangential vector can also be set by the user by specifying an array with the matching number of vectors.
compensate: bool: If True, adds a compensation algorithm if the curve is closed. For a closed curve the moving Frenet algorithm can be continued back to the first point. If the resulting binormial does not coincide with the starting one, some torsion is added to the end portions of the curve to make the two binormals coincide.
This feature is off by default because it is currently experimental and is likely to change in future. It may also form the base for setting the starting as well as the ending binormal.
Returns:
Return a deep copy of the Geometry object.
The returned object is an exact copy of the input, but has all of its data independent of the former.
Partition a Geometry (Formex/Mesh) according to the values in prop.
Parameters:
Returns a list of Geometry objects of the same type as the input. Each object contains all the elements having the same value of prop. The number of objects in the list is equal to the number of unique values in prop. The list is sorted in ascending order of their prop value.
It prop is None and the the object has no prop attribute, an empty list is returned.
Return a copy of the Geometry scaled to the given size.
size can be a single value or a list of three values for the three coordinate directions. If it is a single value, all directions are scaled to the same size. Directions for which the geometry has a size smaller than tol times the maximum size are not rescaled.
Approximate a Curve with a PolyLine of n segments
Parameters:
Note
This is an alternative for Curve.approx, and may replace it in future.
Convert a curve to a Formex.
This creates a polyline approximation as a plex-2 Formex. This is mainly used for drawing curves that do not implement their own drawing routines.
The method can be passed the same arguments as the approx method.
Create or destroy the property array for the Formex.
A property array is a rank-1 integer array with dimension equal to the number of elements in the Formex (first dimension of data). You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.
If a value None is given, the properties are removed from the Formex.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
Functions defined in module curve
Create a spline approximation of a circle.
The returned circle lies in the x,y plane, has its center at (0,0,0) and has a radius 1.
In the current implementation it is approximated by a bezier spline with curl 0.375058 through 8 points.
Create an arc between two points
Given two points x0 and x1, this constructs an arc with radius R through these points. The two points should have the same z-value. The arc will be in a plane parallel with the x-y plane and wind positively around the z-axis when moving along the arc from x0 to x1.
If pos == ‘-‘, the center of the arc will be at the left when going along the chord from x0 to x1, creating an arc smaller than a half-circle. If pos == ‘+’, the center of the arc will be at the right when going along the chord from x0 to x1, creating an arc larger than a half-circle.
If R is too small, an exception is raised.
Convert a Formex to a Curve.
The following Formices can be converted to a Curve: - plex 2 : to PolyLine - plex 3 : to BezierSpline with degree=2 - plex 4 : to BezierSpline