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.

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
Attributes:
framecompas.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.

lengthfloat, read-only

Compute the length of the curve.

startcompas.geometry.Point, read-only

The start point of the polyline.

endcompas.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.

Methods

append

Append a point to the end of the polyline.

divide

Divide a polyline in equal segments.

divide_at_corners

Divides a polyline at corners larger than the given angle_threshold

divide_by_length

Divide a polyline in segments of a given length.

extend

Extends a polyline by a given length, by modifying the first and/or last point tangentially.

extended

Returns a copy of this polyline extended by a given length.

insert

Insert a point at the specified index.

parameter_at

Parameter of the polyline at a specific point.

point_at

Point on the polyline at a specific normalized parameter.

shorten

Shortens a polyline by a given length.

shortened

Returns a copy of this polyline shortened by a given length.

split

Split a polyline in equal segments.

split_at_corners

Splits a polyline at corners larger than the given angle_threshold

split_by_length

Split a polyline in segments of a given length.

tangent_at

Tangent vector at a specific normalized parameter.

tangent_at_point

Calculates the tangent vector of a point on a polyline

transform

Transform this polyline.

Inherited Methods

ToString

Converts the instance to a string.

aabb

Compute the axis-aligned bounding box of the curve.

closest_point

Compute the closest point on the curve to a given point.

compute_aabb

Compute the axis-aligned bounding box of the geometry.

compute_obb

Compute the oriented bounding box of the geometry.

copy

Make an independent copy of the data object.

curvature_at

Compute the curvature vector of the curve at a parameter.

divide_by_count

Compute the curve parameters that divide the curve into a specific number of equal length segments.

fair

frame_at

Compute the local frame of the curve at a parameter.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

from_obj

Load a curve from an OBJ file.

from_step

Load a curve from a STP file.

normal_at

Compute the normal of the curve at a parameter.

offset

reverse

Reverse the parametrisation of the curve.

reversed

Reverse a copy of the curve.

rotate

Rotate the geometry.

rotated

Returns a rotated copy of this geometry.

scale

Scale the geometry.

scaled

Returns a scaled copy of this geometry.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

smooth

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

to_obj

Write the curve geometry to an OBJ file.

to_points

Convert the curve to a list of points.

to_polygon

Convert the curve to a polygon.

to_polyline

Convert the curve to a polyline.

to_step

Write the curve geometry to a STP file.

transformed

Returns a transformed copy of this geometry.

translate

Translate the geometry.

translated

Returns a translated copy of this geometry.

trim

validate_data

Validate the data against the object's data schema.