Polyline
- class compas.geometry.Polyline[source]
Bases:
Curve
A polyline is a curve defined by a sequence of points connected by line segments.
A Polyline can be open or closed. It can be self-intersecting. It does not have an interior.
The parameter space is defined along the consecutive direction vectors of the line segments of the polyline. The coordinate system of the parametrisation is the world coordinate system. Transformations of polylines are defined as transformations of the points defining the polyline.
- Parameters:
- pointslist[[float, float, float] |
compas.geometry.Point
] An ordered list of points. Each consecutive pair of points forms a segment of the polyline.
- namestr, optional
The name of the polyline.
- pointslist[[float, float, float] |
- Attributes:
- frame
compas.geometry.Frame
, read-only The frame of the spatial coordinates of the polyline. This is always the world XY frame.
- pointslist[
compas.geometry.Point
] The points of the polyline.
- lineslist[
compas.geometry.Line
], read-only The lines of the polyline.
length
float, read-onlyCompute the length of the curve.
- start
compas.geometry.Point
, read-only The start point of the polyline.
- end
compas.geometry.Point
, read-only The end point of the polyline.
- is_selfintersectingbool, read-only
True if the polyline is self-intersecting.
- is_closedbool, read-only
True if the polyline is closed.
- frame
Examples
>>> polyline = Polyline([[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0]]) >>> polyline.length 3.0
>>> type(polyline.points[0]) == Point True >>> polyline.points[0].x 0.0
>>> type(polyline.lines[0]) == Line True >>> polyline.lines[0].length 1.0
Methods
Append a point to the end of the polyline.
Divide a polyline in equal segments.
Divides a polyline at corners larger than the given angle_threshold
Divide a polyline in segments of a given length.
Extends a polyline by a given length, by modifying the first and/or last point tangentially.
Returns a copy of this polyline extended by a given length.
Insert a point at the specified index.
Parameter of the polyline at a specific point.
Point on the polyline at a specific normalized parameter.
Shortens a polyline by a given length.
Returns a copy of this polyline shortened by a given length.
Split a polyline in equal segments.
Splits a polyline at corners larger than the given angle_threshold
Split a polyline in segments of a given length.
Tangent vector at a specific normalized parameter.
Calculates the tangent vector of a point on a polyline
Transform this polyline.
Inherited Methods
Converts the instance to a string.
Compute the axis-aligned bounding box of the curve.
Compute the closest point on the curve to a given point.
Compute the axis-aligned bounding box of the geometry.
Compute the oriented bounding box of the geometry.
Make an independent copy of the data object.
Compute the curvature vector of the curve at a parameter.
Compute the curve parameters that divide the curve into a specific number of equal length segments.
Compute the local frame of the curve at a parameter.
Construct an object of this type from a JSON file.
Construct an object of this type from a JSON string.
Construct a parametric curve from a native curve geometry.
Load a curve from an OBJ file.
Load a curve from a STP file.
Compute the normal of the curve at a parameter.
Reverse the parametrisation of the curve.
Reverse a copy of the curve.
Rotate the geometry.
Returns a rotated copy of this geometry.
Scale the geometry.
Returns a scaled copy of this geometry.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation and save it to a JSON file.
Convert an object to its native data representation and save it to a JSON string.
Write the curve geometry to an OBJ file.
Convert the curve to a list of points.
Convert the curve to a polygon.
Convert the curve to a polyline.
Write the curve geometry to a STP file.
Returns a transformed copy of this geometry.
Translate the geometry.
Returns a translated copy of this geometry.
Validate the data against the object's data schema.