ladybug_geometry.geometry2d.polyline module¶
2D Polyline
- class ladybug_geometry.geometry2d.polyline.Polyline2D(vertices, interpolated=False)[source]¶
Bases:
Base2DIn2D
2D polyline object.
- Parameters:
vertices – A list of Point2D objects representing the vertices of the polyline.
interpolated – Boolean to note whether the polyline should be interpolated between the input vertices when it is translated to other interfaces. Note that this property has no bearing on the geometric calculations performed by this library and is only present in order to assist with display/translation.
- Properties:
vertices
segments
min
max
center
p1
p2
length
is_self_intersecting
interpolated
- ToString()¶
Overwrite .NET ToString.
- duplicate()¶
Get a copy of this object.
- classmethod from_array(point_array)[source]¶
Create a Polyline2D from a nested array of vertex coordinates.
- Parameters:
point_array – Nested array of point arrays.
- classmethod from_dict(data)[source]¶
Create a Polyline2D from a dictionary.
- Parameters:
data – A python dictionary in the following format.
{ "type": "Polyline2D", "vertices": [(0, 0), (10, 0), (0, 10)] }
- classmethod from_polygon(polygon)[source]¶
Create a closed Polyline2D from a Polygon2D.
- Parameters:
polygon – A Polygon2D object to be converted to a Polyline2D.
- intersect_line_infinite(ray)[source]¶
Get the intersections between this polyline and a Ray2D extended infinitely.
- Parameters:
ray – A Ray2D or to intersect. This will be extended in both directions infinitely for the intersection.
- Returns:
A list with Point2D objects for the intersections. List will be empty if no intersection exists.
- intersect_line_ray(line_ray)[source]¶
Get the intersections between this polyline and a Ray2D or LineSegment2D.
- Parameters:
line_ray – A LineSegment2D or Ray2D or to intersect.
- Returns:
A list with Point2D objects for the intersections. List will be empty if no intersection exists.
- is_closed(tolerance)[source]¶
Test whether this polyline is closed to within the tolerance.
- Parameters:
tolerance – The minimum difference between vertices below which vertices are considered the same.
- static join_segments(segments, tolerance)[source]¶
Get an array of Polyline2Ds from a list of LineSegment2Ds.
- Parameters:
segments – An array of LineSegment2D objects.
tolerance – The minimum difference in X, Y, and Z values at which Point2Ds are considered equivalent. Segments with points that match within the tolerance will be joined.
- Returns:
An array of Polyline2D and LineSegment2D objects assembled from the joined segments.
- move(moving_vec)[source]¶
Get a polyline that has been moved along a vector.
- Parameters:
moving_vec – A Vector2D with the direction and distance to move the polyline.
- offset(distance, check_intersection=False)[source]¶
Offset the polyline by a given distance.
Note that the resulting shape may be self-intersecting if the distance is large enough and the is_self_intersecting property may be used to identify these shapes.
- Parameters:
distance – The distance that the polyline will be offset. Both positive and negative values are accepted with positive values being offset to the left of the polyline line and negative values being offset to the right of the polyline (starting from the first polyline point and continuing down the polyline).
check_intersection – A boolean to note whether the resulting operation should be checked for self intersection and, if so, None will be returned instead of the self-intersecting polyline.
- reflect(normal, origin)[source]¶
Get a polyline reflected across a plane with the input normal and origin.
- Parameters:
normal – A Vector2D representing the normal vector for the plane across which the polyline will be reflected. THIS VECTOR MUST BE NORMALIZED.
origin – A Point2D representing the origin from which to reflect.
- remove_colinear_vertices(tolerance)[source]¶
Get a version of this polyline without colinear or duplicate vertices.
- Parameters:
tolerance – The minimum distance that a vertex can be from a line before it is considered colinear.
- rotate(angle, origin)[source]¶
Get a polyline that is rotated counterclockwise by a certain angle.
- Parameters:
angle – An angle for rotation in radians.
origin – A Point2D for the origin around which the point will be rotated.
- scale(factor, origin=None)[source]¶
Scale a polyline by a factor from an origin point.
- Parameters:
factor – A number representing how much the polyline should be scaled.
origin – A Point2D representing the origin from which to scale. If None, it will be scaled from the World origin (0, 0).
- to_polygon(tolerance)[source]¶
Get a Polygon2D derived from this object.
If the polyline is closed to within the tolerance, the segments of this polyline and the resulting polygon will match. Otherwise, an extra LineSegment2D will be added to connect the start and end of the polyline.
- Parameters:
tolerance – The minimum difference between vertices below which vertices are considered the same.
- property center¶
A Point2D for the center of the bounding rectangle around this geometry.
- property interpolated¶
Boolean noting whether the polyline should be interpolated upon translation.
Note that this property has no bearing on the geometric calculations performed by this library and is only present in order to assist with display/translation.
- property is_self_intersecting¶
Boolean noting whether the polyline has self-intersecting segments.
- property length¶
The length of the polyline.
- property max¶
A Point2D for the maximum bounding rectangle vertex around this geometry.
- property min¶
A Point2D for the minimum bounding rectangle vertex around this geometry.
- property p1¶
Starting point of the Polyline2D.
- property p2¶
End point of the Polyline2D.
- property segments¶
Tuple of all line segments in the polyline.
- property vertices¶
Tuple of all vertices in this object.