A Polyline3d represents a sequence of vertices connected by line segments.
Polylines can be constructed by passing an ordered list of vertices to the
Polyline3d constructor, for example
examplePolyline =
Polyline3d
[ Point2d ( 0, 0, 0 )
, Point2d ( 1, 0, 0 )
, Point2d ( 1, 2, 0 )
, Point2d ( 1, 2, 3 )
]Get the individual segments of a polyline.
Polyline3d.segments examplePolyline
--> [ LineSegment3d ( Point3d ( 0, 0, 0 ), Point3d ( 1, 0, 0 ) )
--> , LineSegment3d ( Point3d ( 1, 0, 0 ), Point3d ( 1, 2, 0 ) )
--> , LineSegment3d ( Point3d ( 1, 2, 0 ), Point3d ( 1, 2, 3 ) )
--> ]Get the overall length of a polyline (the sum of the lengths of its segments).
Polyline3d.length examplePolyline
--> 6Transforming a polyline is equivalent to transforming each of its vertices.
Scale a polyline about the given center point by the given scale.
point =
Point3d ( 1, 0, 0 )
Polyline3d.scaleAbout point 2 examplePolyline
--> Polyline3d
--> [ Point3d ( -1, 0, 0 )
--> , Point3d ( 1, 0, 0 )
--> , Point3d ( 1, 4, 0 )
--> , Point3d ( 1, 4, 6 )
--> ]Rotate a polyline around the given axis by the given angle (in radians).
Polyline3d.rotateAround Axis3d.z (degrees 90) examplePolyline
--> Polyline3d
--> [ Point3d ( 0, 0, 0 )
--> , Point3d ( 0, 1, 0 )
--> , Point3d ( -2, 1, 0 )
--> , Point3d ( -2, 1, 3 )
--> ]Translate a polyline by the given displacement.
displacement =
Vector3d ( 1, 2, 3 )
Polyline3d.translateBy displacement examplePolyline
--> Polyline3d
--> [ Point3d ( 1, 2, 3 )
--> , Point3d ( 2, 2, 3 )
--> , Point3d ( 2, 4, 3 )
--> , Point3d ( 2, 4, 6 )
--> ]Mirror a polyline across the given plane.
Polyline3d.mirrorAcross Plane3d.xz examplePolyline
--> Polyline3d
--> [ Point3d ( 0, 0, 0 )
--> , Point3d ( 1, 0, 0 )
--> , Point3d ( 1, -2, 0 )
--> , Point3d ( 1, -2, 3 )
--> ]Project (flatten) a polyline onto the given plane.
Polyline3d.projectOnto Plane3d.xz examplePolyline
--> Polyline3d
--> [ Point3d ( 0, 0, 0 )
--> , Point3d ( 1, 0, 0 )
--> , Point3d ( 1, 0, 0 )
--> , Point3d ( 1, 0, 3 )
--> ]Transform each vertex of a polyline by the given function. All other
transformations can be defined in terms of map; for example,
Polyline3d.mirrorAcross Plane3d.xz polylineis equivalent to
Polyline3d.map (Point3d.mirrorAcross Plane3d.xz) polylineTake a polyline defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.
localFrame =
Frame3d.at (Point3d ( 1, 2, 3 ))
Polyline3d.relativeTo localFrame examplePolyline
--> Polyline3d
--> [ Point3d ( -1, -2, -3 )
--> , Point3d ( 0, -2, -3 )
--> , Point3d ( 0, 0, -3 )
--> , Point3d ( 0, 0, 0 )
--> ]Take a polyline considered to be defined in local coordinates relative to a given reference frame, and return that polyline expressed in global coordinates.
localFrame =
Frame3d.at (Point3d ( 1, 2, 3 ))
Polyline3d.placeIn localFrame examplePolyline
--> Polyline3d
--> [ Point3d ( 1, 2, 3 )
--> , Point3d ( 2, 2, 3 )
--> , Point3d ( 2, 4, 3 )
--> , Point3d ( 2, 4, 6 )
--> ]Project a polyline into a given sketch plane. Conceptually, this projects the polyline onto the plane and then expresses the projected polyline in 2D sketch coordinates.
Polyline3d.projectInto Plane3d.xy examplePolyline
--> Polyline2d
--> [ Point2d ( 0, 0 )
--> , Point2d ( 1, 0 )
--> , Point2d ( 1, 2 )
--> , Point2d ( 1, 2 )
--> ]Get the minimal bounding box containing a given polyline. Returns Nothing
if the polyline has no vertices.
Polyline3d.boundingBox examplePolyline
--> Just
--> (BoundingBox3d
--> { minX = 0
--> , maxX = 1
--> , minY = 0
--> , maxY = 2
--> , minZ = 0
--> , maxZ = 3
--> }
--> )
Get the vertices of a polyline.