Polyline

class compas.geometry.Polyline(points)[source]

Bases: compas.geometry.primitives._primitive.Primitive

A polyline is a sequence of points connected by line segments.

A polyline is a piecewise linear element. It does not have an interior. It can be open or closed. It can be self-intersecting.

Parameters

points (list of point) – An ordered list of points. Each consecutive pair of points forms a segment of the polyline.

Attributes
  • data (dict) – The data representation of the polyline.

  • points (list of compas.geometry.Point) – The polyline points.

  • lines (list of compas.geometry.Line, read-only) – The polyline segments.

  • length (float, read-only) – The length 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

Methods

from_data(data)

Construct a polyline from a data dict.

is_closed()

Determine if the polyline is closed.

is_selfintersecting()

Determine if the polyline is self-intersecting.

point(t[, snap])

Point on the polyline at a specific normalized parameter.

transform(T)

Transform this polyline.

Inherited Methods

copy()

Makes a copy of this primitive.

from_json(filepath)

Construct a primitive from structured data contained in a json file.

to_data()

Returns the data dictionary that represents the primitive.

to_json(filepath)

Serialise the structured data representing the primitive to json.

transformed(transformation)

Returns a transformed copy of this primitive.

validate_data()

Validate the data of this object against its data schema (self.DATASCHEMA).

validate_json()

Validate the data loaded from a JSON representation of the data of this object against its data schema (self.DATASCHEMA).