Polyline
- class Polyline
Bases:
CommonBaseModel
Represents a polyline, a series of connected 3D points forming a continuous line or path.
Useful in geometric modeling and spatial analysis, the Polyline class enables the representation of linear paths, edges, or trajectories in three-dimensional space, facilitating calculations and visualizations related to lines.
Attributes Summary
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Methods Summary
add_point
(point)Add a new point object to the end of the polyline, extending its path.
length
()Calculate the total length of the polyline by summing the distances between consecutive points.
simplify
(tolerance)Simplify the polyline by removing redundant points based on a specified tolerance.
validate_points
(value)Validate the 'points' list to ensure it contains at least two points.
Attributes Documentation
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'protected_namespaces': (), 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Methods Documentation
- add_point(point)
Add a new point object to the end of the polyline, extending its path.
- Parameters:
point (Point) – The point object to be appended to the polyline.
- Return type:
None
- length()
Calculate the total length of the polyline by summing the distances between consecutive points.
- Returns:
The total length of the polyline.
- Return type:
float
- simplify(tolerance)
Simplify the polyline by removing redundant points based on a specified tolerance.
The simplification algorithm iteratively removes points that deviate from the line segment formed by their neighboring points by a distance less than the specified tolerance. This process continues until no more points can be removed without exceeding the tolerance.
- Parameters:
tolerance (float) – The maximum deviation allowed for a point to be considered redundant.
- Returns:
A new simplified polyline with redundant points removed.
- Return type:
- classmethod validate_points(value)
Validate the ‘points’ list to ensure it contains at least two points.
Methods:
validate_points
(value)Validate the 'points' list to ensure it contains at least two points.
add_point
(point)Add a new point object to the end of the polyline, extending its path.
length
()Calculate the total length of the polyline by summing the distances between consecutive points.
simplify
(tolerance)Simplify the polyline by removing redundant points based on a specified tolerance.
Attributes:
__setattr__ handlers.
- classmethod validate_points(value)
Validate the ‘points’ list to ensure it contains at least two points.
- add_point(point)
Add a new point object to the end of the polyline, extending its path.
- Parameters:
point (Point) – The point object to be appended to the polyline.
- Return type:
None
- length()
Calculate the total length of the polyline by summing the distances between consecutive points.
- Returns:
The total length of the polyline.
- Return type:
float
- simplify(tolerance)
Simplify the polyline by removing redundant points based on a specified tolerance.
The simplification algorithm iteratively removes points that deviate from the line segment formed by their neighboring points by a distance less than the specified tolerance. This process continues until no more points can be removed without exceeding the tolerance.
- Parameters:
tolerance (float) – The maximum deviation allowed for a point to be considered redundant.
- Returns:
A new simplified polyline with redundant points removed.
- Return type:
- __pydantic_setattr_handlers__: ClassVar[Dict[str, Callable[[BaseModel, str, Any], None]]] = {}
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__