A Polyline3d represents a sequence of vertices in 3D connected by line
segments. This module contains a variety of polyline-related functionality, such
as
Construct a polyline from its vertices:
examplePolyline =
Polyline3d.fromVertices
[ Point3d.meters 0 0 0
, Point3d.meters 1 0 0
, Point3d.meters 1 2 0
, Point3d.meters 1 2 3
]Construct a 3D polyline lying on a sketch plane by providing a 2D polyline specified in XY coordinates within the sketch plane.
Polyline3d.on SketchPlane3d.yz <|
Polyline2d.fromVertices
[ Point2d.meters 0 0
, Point2d.meters 1 0
, Point2d.meters 1 1
, Point2d.meters 2 1
]
--> Polyline3d.fromVertices
--> [ Point3d.meters 0 0 0
--> , Point3d.meters 0 1 0
--> , Point3d.meters 0 1 1
--> , Point3d.meters 0 2 1
--> ]Get the vertices of a polyline.
Get the individual segments of a polyline.
Polyline3d.segments examplePolyline
--> [ LineSegment3d.from
--> (Point3d.meters 0 0 0)
--> (Point3d.meters 1 0 0)
--> , LineSegment3d.from
--> (Point3d.meters 1 0 0)
--> (Point3d.meters 1 2 0)
--> , LineSegment3d.from
--> (Point3d.meters 1 2 0)
--> (Point3d.meters 1 2 3)
--> ]Get the overall length of a polyline (the sum of the lengths of its segments).
Polyline3d.length examplePolyline
--> Length.meters 6Get the minimal bounding box containing a given polyline. Returns Nothing
if the polyline has no vertices.
Polyline3d.boundingBox examplePolyline
--> Just <|
--> BoundingBox3d.from
--> (Point3d.meters 0 0 0)
--> (Point3d.meters 1 2 3)Find the centroid (center of mass) of a polyline. This is the
length-weighted average of the edges of the polyline, not the centroid of its
vertices. Returns Nothing if the polyline is empty (has no vertices).
Polyline3d.centroid examplePolyline
--> Just (Point3d.meters 0.9167 1.333 0.75)These transformations generally behave just like the ones in the Point3d
module.
Scale a polyline about the given center point by the given scale.
Rotate a polyline around the given axis by the given angle.
Translate a polyline by the given displacement.
Translate a polyline in a given direction by a given distance.
Mirror a polyline across the given plane.
Find the orthographic projection of a polyline onto a plane. This will flatten the polyline.
Transform each vertex of a polyline by the given function. All other
transformations can be defined in terms of mapVertices; for example,
Polyline3d.mirrorAcross planeis equivalent to
Polyline3d.mapVertices (Point3d.mirrorAcross plane)Convert a polyline from one units type to another, by providing a conversion factor given as a rate of change of destination units with respect to source units.
Convert a polyline from one units type to another, by providing an 'inverse' conversion factor given as a rate of change of source units with respect to destination units.
Take a polyline defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.
Take a polyline considered to be defined in local coordinates relative to a given reference frame, and return that polyline expressed in global coordinates.
Project a polyline into a given sketch plane.