Logo Euclid

Polyline2D Type

A class holding a list of 2D points representing a mutable 2D Polyline. If the last point is the same as the first point, the Polyline2D is considered closed. The source-of-truth storage is an interleaved float buffer: x0, y0, x1, y1, ... The instance members for transformations, like Move, Scale or Rotate, and for clean up, like Reverse, Close or RemoveDuplicatePoints, mutate the Polyline2D in place and return unit. Their static counterparts, like Polyline2D.move, Polyline2D.reverse or Polyline2D.removeDuplicatePoints, return a new Polyline2D and leave the input unchanged. The indexed point setters and movers, setPoint, setPointPreservingClosure, setXY, setXYPreservingClosure, movePoint, moveXY, movePointPreservingClosure and moveXYPreservingClosure, and the append functions addPoint and addXY mutate in place and return unit, as instance and as static members. Taking a point index alone does not mean mutation: getPoint, getX, getY and getLine only read the Polyline2D. XYs and xys expose the live coordinate buffer, changes to it change the Polyline2D.

Constructors

Constructor Description

Polyline2D(capacity)

Full Usage: Polyline2D(capacity)

Parameters:
    capacity : int

Returns: Polyline2D

Create a new empty Polyline2D with predefined point count capacity.

capacity : int
Returns: Polyline2D

Instance members

Instance member Description

this.AddPoint

Full Usage: this.AddPoint

Parameters:

Adds a point to the end of the Polyline2D.

pt : Pt

this.AddXY

Full Usage: this.AddXY

Parameters:
    x : float
    y : float

Adds a point from x and y coordinates.

x : float
y : float

this.Area

Full Usage: this.Area

Returns: float

Calculates the area of the Polyline2D. The segment from the last point to the first point is included in the area calculation. For self-intersecting Polylines the result is invalid.

Returns: float

this.AsFSharpCode

Full Usage: this.AsFSharpCode

Returns: string

Format a 2D polyline into an F# code string that can be used to recreate the polyline.

Returns: string

this.AsPoints

Full Usage: this.AsPoints

Returns: ResizeArray<Pt>

Converts the float buffer of the Polyline2D into a list of Points. Use .XYs to access the live internal buffer.

Returns: ResizeArray<Pt>

this.AsString

Full Usage: this.AsString

Returns: string

Format Polyline2D into string including its length.

Returns: string

this.BoundingRectangle

Full Usage: this.BoundingRectangle

Returns: BRect

Gets bounding rectangle of the Polyline2D

Returns: BRect

this.Center

Full Usage: this.Center

Returns: Pt

Returns the average center of all points of the Polyline2D.

Returns: Pt

this.Clone

Full Usage: this.Clone

Returns: Polyline2D

Creates a copy of the Polyline2D. Same as polyline.Duplicate()

Returns: Polyline2D

this.Close

Full Usage: this.Close

Parameters:
    ?toleranceForAddingPoint : float - Optional. 1e-6 by default The tolerance used to decide whether to snap the last point to the first point.

Closes the Polyline2D in place if it is not already closed. If the ends are closer than the tolerance, the last point is set equal to the first point. Otherwise the start point is added to the end of the Polyline2D. Raises an error if the Polyline2D has fewer than 3 points.

?toleranceForAddingPoint : float

Optional. 1e-6 by default The tolerance used to decide whether to snap the last point to the first point.

this.ClosestParameter

Full Usage: this.ClosestParameter

Parameters:
Returns: float

Returns the parameter on the Polyline2D that is the closest point to the given point. The integer part of the parameter is the index of the segment that the point is on. The fractional part of the parameter is the parameter from 0.0 to 1.0 on the segment. The domain Polyline2D starts at 0.0 and ends at points.Count - 1.0 .

p : Pt
Returns: float

this.ClosestParameterXY

Full Usage: this.ClosestParameterXY

Parameters:
    x : float
    y : float

Returns: float

Returns the parameter on the Polyline2D that is the closest point to the given point. The integer part of the parameter is the index of the segment that the point is on. The fractional part of the parameter is the parameter from 0.0 to 1.0 on the segment. The domain Polyline2D starts at 0.0 and ends at points.Count - 1.0 .

x : float
y : float
Returns: float

this.ClosestPoint

Full Usage: this.ClosestPoint

Parameters:
Returns: Pt

Returns the point on the Polyline2D that is the closest point to the given point. This might be a point on a segment or a vertex of the Polyline2D.

p : Pt
Returns: Pt

this.ClosestPointIndex

Full Usage: this.ClosestPointIndex

Parameters:
Returns: int

Returns the index into the Polyline2D's point list of the point that is closest to the given point.

p : Pt
Returns: int

this.ContainsPt

Full Usage: this.ContainsPt

Parameters:
    pt : Pt - The point to test.

Returns: bool TRUE if the point is inside, FALSE otherwise.

Tests if a point is inside the closed Polyline2D using the ray casting algorithm.

The first and last point of the Polyline2D need to be identical for correct results. Self-intersecting polygons give "alternating" inside/outside regions Uses ray casting: runs an infinite horizontal ray (increasing x, fixed y) from the test point and counts edge crossings. Each crossing toggles inside/outside state (Jordan curve theorem). Always returns FALSE if the Polyline2D has fewer than 3 points. Boundary cases: Points exactly on edges or vertices have implementation-specific behavior. Horizontal edges are handled by the strict inequality convention (pi.Y > y) != (pj.Y > y). Points on left/bottom edges tend to be considered inside, right/top edges outside. The result may differ from checking the pl.WindingNumber 0 for boundary points.

pt : Pt

The point to test.

Returns: bool

TRUE if the point is inside, FALSE otherwise.

this.ContainsXY

Full Usage: this.ContainsXY

Parameters:
    x : float - The X coordinate of the point to test.
    y : float - The Y coordinate of the point to test.

Returns: bool TRUE if the point is inside, FALSE otherwise.

Tests if a point is inside the closed Polyline2D using the ray casting algorithm.

The first and last point of the Polyline2D need to be identical for correct results. Self-intersecting polygons give "alternating" inside/outside regions Uses ray casting: runs an infinite horizontal ray (increasing x, fixed y) from the test point and counts edge crossings. Each crossing toggles inside/outside state (Jordan curve theorem). Always returns FALSE if the Polyline2D has fewer than 3 points. Boundary cases: Points exactly on edges or vertices have implementation-specific behavior. Horizontal edges are handled by the strict inequality convention (pi.Y > y) != (pj.Y > y). Points on left/bottom edges tend to be considered inside, right/top edges outside. The result may differ from checking the pl.WindingNumber 0 for boundary points.

x : float

The X coordinate of the point to test.

y : float

The Y coordinate of the point to test.

Returns: bool

TRUE if the point is inside, FALSE otherwise.

this.DistanceToPt

Full Usage: this.DistanceToPt

Parameters:
Returns: float

Returns the distance of the test point to the closest point on the Polyline2D.

p : Pt
Returns: float

this.DistanceToPtSigned

Full Usage: this.DistanceToPtSigned

Parameters:
Returns: float

Calculates the shortest distance from the test point to the polyline with `DistanceToXY`, then signs that value by testing containment via the ray-casting based `ContainsXY` helper. Returns a positive distance for points that lie inside the polyline boundary and negative otherwise. For reliable results the polyline should be closed and have identical first and last vertices.

pt : Pt
Returns: float

this.DistanceToXY

Full Usage: this.DistanceToXY

Parameters:
    x : float
    y : float

Returns: float

Returns the distance of the test point to the closest point on the Polyline2D.

x : float
y : float
Returns: float

this.DistanceToXYSigned

Full Usage: this.DistanceToXYSigned

Parameters:
    x : float
    y : float

Returns: float

Calculates the shortest distance from the test point to the polyline with `DistanceToXY`, then signs that value by testing containment via the ray-casting based `ContainsXY` helper. Returns a positive distance for points that lie inside the polyline boundary and negative otherwise. For reliable results the polyline should be closed and have identical first and last vertices.

x : float
y : float
Returns: float

this.Duplicate

Full Usage: this.Duplicate

Returns: Polyline2D

Creates a copy of the Polyline2D Same as polyline.Clone()

Returns: Polyline2D

this.End

Full Usage: this.End

Returns: Pt

Gets or sets the last or end point of the Polyline2D. This is the point at index Points.Count - 1. Same as Polyline2D.LastPoint Setting it mutates the Polyline2D in place and moves only this one point, so a closed Polyline2D gets opened. Use SetXYPreservingClosure or MovePointPreservingClosure to keep it closed.

Returns: Pt

this.EnsureClockwise

Full Usage: this.EnsureClockwise

Tests if the Polyline2D is Clockwise. If not, reverses the Polyline2D in place. Raises an error if the area of the Polyline2D is zero.

this.EnsureCounterClockwise

Full Usage: this.EnsureCounterClockwise

Tests if the Polyline2D is counter-clockwise. If not, reverses the Polyline2D in place. Raises an error if the area of the Polyline2D is zero.

this.EvaluateAt

Full Usage: this.EvaluateAt

Parameters:
    t : float

Returns: Pt

Returns the point at a given parameter on the Polyline2D. The integer part of the parameter is the index of the segment that the point is on. The fractional part of the parameter is the parameter from 0.0 to 1.0 on the segment. The domain Polyline2D starts at 0.0 and ends at points.Count - 1.0 . If the parameter is within 1e-6 of an integer value, the integer value is used as parameter.

t : float
Returns: Pt

this.FindLabelPoint

Full Usage: this.FindLabelPoint

Parameters:
    precision : float

Returns: Pt * float

Finds a point inside a closed Polyline2D that is the farthest away from the edges of the Polyline2D. Uses the Polylabel algorithm from Mapbox. It is a highly optimized algorithm specifically designed to find the pole of inaccessibility for polygons. The point within the polygon that is farthest from the edges, often used for optimal label placement. Adaptive Precision: Can trade accuracy for speed based on your needs. The precision must be a positive number, otherwise an error is raised. Returns the best point and its distance to the polygon edge. Supplying an open polyline is allowed, but the computed "inside" still assumes the points describe a closed boundary (first and last vertices should match).

precision : float
Returns: Pt * float

this.FirstPoint

Full Usage: this.FirstPoint

Returns: Pt

Gets or sets the first point of the Polyline2D. This is the point at index 0. Same as Polyline2D.Start Setting it mutates the Polyline2D in place and moves only this one point, so a closed Polyline2D gets opened. Use SetXYPreservingClosure or MovePointPreservingClosure to keep it closed.

Returns: Pt

this.FirstSegment

Full Usage: this.FirstSegment

Returns: Line2D

Gets the first segment of the Polyline2D.

Returns: Line2D

this.GetPoint

Full Usage: this.GetPoint

Parameters:
    pointIndex : int

Returns: Pt

Gets the 2D point at the given pointIndex in the list of points. (this gets Pt(XYs.[pointIndex * 2], XYs.[pointIndex * 2 + 1]) from the internal flat list of x and y coordinates )

pointIndex : int
Returns: Pt

this.GetSegment

Full Usage: this.GetSegment

Parameters:
    i : int

Returns: Line2D

Gets the segment at index i of the Polyline2D.

i : int
Returns: Line2D

this.GetX

Full Usage: this.GetX

Parameters:
    pointIndex : int

Returns: float

Gets the x coordinate of the 2D point at the given pointIndex in the list of points. (this gets XYs.[pointIndex * 2] from the internal flat list of x and y coordinates )

pointIndex : int
Returns: float

this.GetY

Full Usage: this.GetY

Parameters:
    pointIndex : int

Returns: float

Gets the y coordinate of the 2D point at the given pointIndex in the list of points. (this gets XYs.[pointIndex * 2 + 1] from the internal flat list of x and y coordinates )

pointIndex : int
Returns: float

this.IsAlmostClosed

Full Usage: this.IsAlmostClosed

Parameters:
    tolerance : float

Returns: bool

Tests if Polyline2D is closed within given tolerance. Returns FALSE if the Polyline2D has fewer than 3 points.

tolerance : float
Returns: bool

this.IsClockwise

Full Usage: this.IsClockwise

Returns: bool

Test if Polyline2D is Clockwise. The Polyline2D does not need to be actually closed. The signed area of the Polyline2D is calculated. If it is negative the Polyline2D is Clockwise.

Returns: bool

this.IsClosed

Full Usage: this.IsClosed

Returns: bool

Tests if Polyline2D start and end points are exactly the same. Returns FALSE if the Polyline2D has fewer than 3 points.

Returns: bool

this.IsCounterClockwise

Full Usage: this.IsCounterClockwise

Returns: bool

Test if Polyline2D is counter-clockwise. The Polyline2D does not need to be actually closed. The signed area of the Polyline2D is calculated. If it is positive the Polyline2D is counter-clockwise.

Returns: bool

this.LastPoint

Full Usage: this.LastPoint

Returns: Pt

Gets or sets the last point of the Polyline2D. This is the point at index Points.Count - 1. Same as Polyline2D.End Setting it mutates the Polyline2D in place and moves only this one point, so a closed Polyline2D gets opened. Use SetXYPreservingClosure or MovePointPreservingClosure to keep it closed.

Returns: Pt

this.LastSegment

Full Usage: this.LastSegment

Returns: Line2D

Gets the last segment of the Polyline2D.

Returns: Line2D

this.Length

Full Usage: this.Length

Returns: float

Gets the length of the Polyline2D. The sum of the lengths of all segments. Returns 0.0 if there are fewer than 2 points.

Returns: float

this.Move

Full Usage: this.Move

Parameters:

Moves the Polyline2D in place by a vector.

v : Vc

this.MovePoint

Full Usage: this.MovePoint

Parameters:
    pointIndex : int - The index of the point to move. Must be between 0 and PointCount - 1.
    v : Vc - The vector to move the point by.

Moves the 2D point at the given pointIndex in place by a vector. NOTE: moving the first or last point on a closed Polyline2D opens it. Use MovePointPreservingClosure to keep it closed. (this adds v.X and v.Y to XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int

The index of the point to move. Must be between 0 and PointCount - 1.

v : Vc

The vector to move the point by.

this.MovePointPreservingClosure

Full Usage: this.MovePointPreservingClosure

Parameters:
    pointIndex : int - The index of the point to move. Must be between 0 and PointCount - 1.
    v : Vc - The vector to move the point by.

Moves the 2D point at the given pointIndex in place by a vector. On a closed Polyline2D, moving the first or last point moves both, so it stays closed. (this adds v.X and v.Y to XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int

The index of the point to move. Must be between 0 and PointCount - 1.

v : Vc

The vector to move the point by.

this.MoveX

Full Usage: this.MoveX

Parameters:
    distance : float

Moves the Polyline2D in place by a given distance in X direction.

distance : float

this.MoveXY

Full Usage: this.MoveXY

Parameters:
    pointIndex : int - The index of the point to move. Must be between 0 and PointCount - 1.
    x : float - The distance to move the point in X direction.
    y : float - The distance to move the point in Y direction.

Moves the 2D point at the given pointIndex in place by the given x and y distances. NOTE: moving the first or last point on a closed Polyline2D opens it. Use MoveXYPreservingClosure to keep it closed. (this adds x and y to XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int

The index of the point to move. Must be between 0 and PointCount - 1.

x : float

The distance to move the point in X direction.

y : float

The distance to move the point in Y direction.

this.MoveXYPreservingClosure

Full Usage: this.MoveXYPreservingClosure

Parameters:
    pointIndex : int - The index of the point to move. Must be between 0 and PointCount - 1.
    x : float - The distance to move the point in X direction.
    y : float - The distance to move the point in Y direction.

Moves the 2D point at the given pointIndex in place by the given x and y distances. On a closed Polyline2D, moving the first or last point moves both, so it stays closed. (this adds x and y to XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int

The index of the point to move. Must be between 0 and PointCount - 1.

x : float

The distance to move the point in X direction.

y : float

The distance to move the point in Y direction.

this.MoveY

Full Usage: this.MoveY

Parameters:
    distance : float

Moves the Polyline2D in place by a given distance in Y direction.

distance : float

this.PointCount

Full Usage: this.PointCount

Returns: int

Gets the number of points in the Polyline2D.

Returns: int

this.RemoveDuplicateAndCollinearPoints

Full Usage: this.RemoveDuplicateAndCollinearPoints

Parameters:

Removes consecutive duplicate points and collinear points from the Polyline2D in place, within given tolerances. This algorithm allows the last and first point to be identical if the Polyline2D is closed. Collinear points are removed when the angle between segments is smaller than the cosine threshold (e.g. cosine of 0.5 degrees ). If the Polyline2D is closed and starts and ends with collinear segments, the first point is replaced with the last non-collinear point. So the joint of the loop is now moved to the last non-collinear point. So that there are no collinear segments even between start and end. Raises an error if all points are within the distanceTolerance of the first point. In that case the Polyline2D is not changed.

angleTolerance : float<MeasureProduct<cosine, MeasureOne>>
distanceTolerance : float

this.RemoveDuplicatePoints

Full Usage: this.RemoveDuplicatePoints

Parameters:
    distanceTolerance : float - The distance within which points are considered duplicates.

Removes consecutive duplicate points from the Polyline2D in place, within a given tolerance.

From a cluster of points that are closer than the distanceTolerance, only the first point is kept. Use 'RemoveDuplicatePointsFaithfully' if you want to keep the edges in their position by re-intersecting segments. The position of start and end point is NOT changed. Use Close to ensure start and end point are identical.

distanceTolerance : float

The distance within which points are considered duplicates.

this.RemoveDuplicatePointsAndReport

Full Usage: this.RemoveDuplicatePointsAndReport

Parameters:
    distanceTolerance : float - The distance within which points are considered duplicates.

Returns: ResizeArray<Pt> The removed duplicate points, with consecutive identical entries listed once per run. An empty list if no duplicates were found and the Polyline2D was not changed.

Removes consecutive duplicate points from the Polyline2D in place, within a given tolerance, and returns them. Same as 'RemoveDuplicatePoints', but also reports the points that were removed.

distanceTolerance : float

The distance within which points are considered duplicates.

Returns: ResizeArray<Pt>

The removed duplicate points, with consecutive identical entries listed once per run. An empty list if no duplicates were found and the Polyline2D was not changed.

this.RemoveDuplicatePointsFaithfully

Full Usage: this.RemoveDuplicatePointsFaithfully

Parameters:
    distanceTolerance : float - The distance within which points are considered duplicates.

Removes consecutive duplicate points from the Polyline2D in place, within a given tolerance.

This algorithm keeps edges in their position by re-intersecting segments if points are closer than the distanceTolerance but not identical. The position of start and end point is NOT changed. Use Close to ensure start and end point are identical.

distanceTolerance : float

The distance within which points are considered duplicates.

this.RemoveUTurns

Full Usage: this.RemoveUTurns

Parameters:

Removes simple sharp U-Turns from the Polyline2D in place.

The Offset2D module also has a removeUTurns function that takes precomputed unit vectors and is therefore more efficient. For nested U-turns and collinear points in U-turns segments use 'RemoveUTurnsDeeply'. That function calls repeatedly until no more U-turns are present.

minCos : float<MeasureProduct<cosine, MeasureOne>>

The angle between segments so that they are considered a U-turn. For example, for 179.9 degrees use 'Cosine.``179.9``'.

this.RemoveUTurnsDeeply

Full Usage: this.RemoveUTurnsDeeply

Parameters:

Removes all sharp U-Turns from the Polyline2D in place, recursively until no more U-turns are present. This function calls 'RemoveUTurns' repeatedly until no more U-turns are present. Use this function when you have nested U-turns and collinear points in U-turns segments.

If an error is raised in any of the repeated calls, the Polyline2D is not changed.

minCos : float<MeasureProduct<cosine, MeasureOne>>

The angle between segments so that they are considered a U-turn. For example, for 179.9 degrees use 'Cosine.``179.9``'.

this.Reverse

Full Usage: this.Reverse

Reverses the order of the Polyline2D in place.

this.Rotate

Full Usage: this.Rotate

Parameters:

Rotates the Polyline2D in place around the world origin by a Rotation2D.

r : Rotation2D

this.RotateAround

Full Usage: this.RotateAround

Parameters:
    cen : Pt - The center point of the rotation.
    r : Rotation2D - The rotation to apply.

Rotates the Polyline2D in place counter-clockwise around a given center point by a Rotation2D.

cen : Pt

The center point of the rotation.

r : Rotation2D

The rotation to apply.

this.RotateDegrees

Full Usage: this.RotateDegrees

Parameters:
    angDegree : float - The rotation angle in degrees.

Rotates the Polyline2D in place counter-clockwise around the world origin by an angle in degrees.

For better performance precompute the Rotation2D struct and rotate with this.Rotate(rotation2D).

angDegree : float

The rotation angle in degrees.

this.RotateDegreesAround

Full Usage: this.RotateDegreesAround

Parameters:
    cen : Pt - The center point of the rotation.
    angDegree : float - The rotation angle in degrees.

Rotates the Polyline2D in place counter-clockwise around a given center point by an angle in degrees.

cen : Pt

The center point of the rotation.

angDegree : float

The rotation angle in degrees.

this.RotateRadians

Full Usage: this.RotateRadians

Parameters:
    angRadians : float - The rotation angle in radians.

Rotates the Polyline2D in place counter-clockwise around the world origin by an angle in radians.

For better performance precompute the Rotation2D struct and rotate with this.Rotate(rotation2D).

angRadians : float

The rotation angle in radians.

this.RotateRadiansAround

Full Usage: this.RotateRadiansAround

Parameters:
    cen : Pt - The center point of the rotation.
    angRadians : float - The rotation angle in radians.

Rotates the Polyline2D in place counter-clockwise around a given center point by an angle in radians.

cen : Pt

The center point of the rotation.

angRadians : float

The rotation angle in radians.

this.Scale

Full Usage: this.Scale

Parameters:
    factor : float

Scales the Polyline2D in place by a given factor. Scale center is World Origin 0,0

factor : float

this.ScaleOn

Full Usage: this.ScaleOn

Parameters:
    cen : Pt - The center point of the scaling.
    factor : float - The scale factor.

Scales the Polyline2D in place by a given factor around a given center point.

cen : Pt

The center point of the scaling.

factor : float

The scale factor.

this.SecondLastPoint

Full Usage: this.SecondLastPoint

Returns: Pt

Gets or sets the second last point of the Polyline2D. Setting it mutates the Polyline2D in place.

Returns: Pt

this.SecondPoint

Full Usage: this.SecondPoint

Returns: Pt

Gets or sets the second point of the Polyline2D. This is the point at index 1. Setting it mutates the Polyline2D in place.

Returns: Pt

this.SegmentCount

Full Usage: this.SegmentCount

Returns: int

Gets the number of segments in the Polyline2D. This is the point count minus one, but never negative.

Returns: int

this.SegmentVectors

Full Usage: this.SegmentVectors

Returns: ResizeArray<Vc>

Returns the line vectors of all segments of the Polyline2D as a list of Vc. The length of the list is one less than the point count.

Returns: ResizeArray<Vc>

this.SegmentVectorsXY

Full Usage: this.SegmentVectorsXY

Returns: ResizeArray<float>

Returns the line vectors of all segments of the Polyline2D as a flat list of x and y components. The length of the list is 2 less than the xys count, so one less vector than points in the polyline.

Returns: ResizeArray<float>

this.Segments

Full Usage: this.Segments

Returns: ResizeArray<Line2D>

Returns all segments of the Polyline2D as a list of Line2D.

Returns: ResizeArray<Line2D>

this.SetPoint

Full Usage: this.SetPoint

Parameters:
    pointIndex : int
    pt : Pt

Sets the 2D point at the given pointIndex in the list of points. (this sets XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int
pt : Pt

this.SetPointPreservingClosure

Full Usage: this.SetPointPreservingClosure

Parameters:
    pointIndex : int
    pt : Pt

Sets the 2D point at the given pointIndex in the list of points. On a closed Polyline2D, setting the first or last point will set both to the same point. Raises an error if the pointIndex is out of range. (this sets XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int
pt : Pt

this.SetXY

Full Usage: this.SetXY

Parameters:
    pointIndex : int
    x : float
    y : float

Sets the x and y coordinates of the 2D point at the given pointIndex in the list of points. NOTE: setting the first or last point on a closed Polyline2D might open it. (this sets XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int
x : float
y : float

this.SetXYPreservingClosure

Full Usage: this.SetXYPreservingClosure

Parameters:
    pointIndex : int
    x : float
    y : float

Sets the x and y coordinates of the 2D point at the given pointIndex in the list of points. On a closed Polyline2D, setting the first or last point will set both to the same point. Raises an error if the pointIndex is out of range. (this sets XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int
x : float
y : float

this.SignedArea

Full Usage: this.SignedArea

Returns: float

Calculates the signed area of the Polyline2D. If it is positive the Polyline2D is counter-clockwise. Polyline does not need to be exactly closed. The segment from the last point to the first point is included in the area calculation. For self-intersecting Polylines the result is invalid. Raises an error on an empty Polyline2D.

Returns: float

this.Start

Full Usage: this.Start

Returns: Pt

Gets or sets the first point of the Polyline2D. This is the point at index 0. Same as Polyline2D.FirstPoint Setting it mutates the Polyline2D in place and moves only this one point, so a closed Polyline2D gets opened. Use SetXYPreservingClosure or MovePointPreservingClosure to keep it closed.

Returns: Pt

this.WindingNumber

Full Usage: this.WindingNumber

Parameters:
    point : Pt - The point to test.

Returns: int The winding number. Zero means outside, non-zero means inside.

Count how many times the polygon winds around the point. If the result is 0 then the point is outside of the Polyline2D. A non-zero value indicates the point is inside.

The first and last point of the Polyline2D need to be identical for correct results. Boundary cases: Points exactly on edges or vertices may return inconsistent results due to floating-point precision. For points on horizontal edges, behavior depends on the edge direction. This method Handles self-intersecting polygons more intuitively than the pl.ContainsPt method.

point : Pt

The point to test.

Returns: int

The winding number. Zero means outside, non-zero means inside.

this.XYs

Full Usage: this.XYs

Returns: ResizeArray<float>

Gets the X and Y interleaved ResizeArray of the Polyline2D: x0, y0, x1, y1, ... This is the live internal buffer, so changes to the list will be reflected in the Polyline2D.

Returns: ResizeArray<float>

Static members

Static member Description

Polyline2D.addPoint pt p

Full Usage: Polyline2D.addPoint pt p

Parameters:
Modifiers: inline

Adds a point to the end of the Polyline2D.

pt : Pt
p : Polyline2D

Polyline2D.addXY x y p

Full Usage: Polyline2D.addXY x y p

Parameters:
Modifiers: inline

Adds a point from x and y coordinates.

x : float
y : float
p : Polyline2D

Polyline2D.area p

Full Usage: Polyline2D.area p

Parameters:
Returns: float
Modifiers: inline

Calculates the area of the Polyline2D. The segment from the last point to the first point is included in the area calculation. For self-intersecting Polylines the result is invalid.

p : Polyline2D
Returns: float

Polyline2D.asFSharpCode p

Full Usage: Polyline2D.asFSharpCode p

Parameters:
Returns: string
Modifiers: inline

Format a 2D polyline into an F# code string that can be used to recreate the polyline.

p : Polyline2D
Returns: string

Polyline2D.asPoints p

Full Usage: Polyline2D.asPoints p

Parameters:
Returns: ResizeArray<Pt>
Modifiers: inline

Converts the float buffer of the Polyline2D into a list of Points. Use .XYs to access the live internal buffer.

p : Polyline2D
Returns: ResizeArray<Pt>

Polyline2D.asString p

Full Usage: Polyline2D.asString p

Parameters:
Returns: string
Modifiers: inline

Format Polyline2D into string including its length.

p : Polyline2D
Returns: string

Polyline2D.boundingRectangle p

Full Usage: Polyline2D.boundingRectangle p

Parameters:
Returns: BRect
Modifiers: inline

Gets bounding rectangle of the Polyline2D

p : Polyline2D
Returns: BRect

Polyline2D.center p

Full Usage: Polyline2D.center p

Parameters:
Returns: Pt
Modifiers: inline

Returns the average center of all points of the Polyline2D.

p : Polyline2D
Returns: Pt

Polyline2D.clone p

Full Usage: Polyline2D.clone p

Parameters:
Returns: Polyline2D
Modifiers: inline

Creates a copy of the Polyline2D. Same as polyline.Duplicate()

p : Polyline2D
Returns: Polyline2D

Polyline2D.close toleranceForAddingPoint pl

Full Usage: Polyline2D.close toleranceForAddingPoint pl

Parameters:
    toleranceForAddingPoint : float - The tolerance used to decide whether to snap the last point to the first point.
    pl : Polyline2D - The Polyline2D to close.

Returns: Polyline2D A new closed Polyline2D. Use p.Close to close in place.

Returns a new closed Polyline2D. The input Polyline2D is not changed. If the ends are closer than the tolerance, the last point is set equal to the first point. Otherwise the start point is added to the end of the Polyline2D. Raises an error if the Polyline2D has fewer than 3 points.

toleranceForAddingPoint : float

The tolerance used to decide whether to snap the last point to the first point.

pl : Polyline2D

The Polyline2D to close.

Returns: Polyline2D

A new closed Polyline2D. Use p.Close to close in place.

Polyline2D.closestParameter pt pl

Full Usage: Polyline2D.closestParameter pt pl

Parameters:
Returns: float
Modifiers: inline

Returns the parameter on the Polyline2D that is the closest point to the given point. The integer part of the parameter is the index of the segment that the point is on. The fractional part of the parameter is the parameter from 0.0 to 1.0 on the segment. The domain Polyline2D starts at 0.0 and ends at points.Count - 1.0 .

pt : Pt
pl : Polyline2D
Returns: float

Polyline2D.closestParameterXY x y pl

Full Usage: Polyline2D.closestParameterXY x y pl

Parameters:
Returns: float
Modifiers: inline

Returns the parameter on the Polyline2D that is the closest point to the given point. The integer part of the parameter is the index of the segment that the point is on. The fractional part of the parameter is the parameter from 0.0 to 1.0 on the segment. The domain Polyline2D starts at 0.0 and ends at points.Count - 1.0 .

x : float
y : float
pl : Polyline2D
Returns: float

Polyline2D.closestPoint pt pl

Full Usage: Polyline2D.closestPoint pt pl

Parameters:
Returns: Pt
Modifiers: inline

Returns the point on the Polyline2D that is the closest point to the given point. This might be a point on a segment or a vertex of the Polyline2D.

pt : Pt
pl : Polyline2D
Returns: Pt

Polyline2D.closestPointIndex pt pl

Full Usage: Polyline2D.closestPointIndex pt pl

Parameters:
Returns: int
Modifiers: inline

Returns the index into the Polyline2D's point list of the point that is closest to the given point.

pt : Pt
pl : Polyline2D
Returns: int

Polyline2D.containsPt pt pl

Full Usage: Polyline2D.containsPt pt pl

Parameters:
    pt : Pt - The point to test.
    pl : Polyline2D - The closed Polyline2D.

Returns: bool TRUE if the point is inside, FALSE otherwise.
Modifiers: inline

Tests if a point is inside the closed Polyline2D using the ray casting algorithm.

The first and last point of the Polyline2D need to be identical for correct results. Self-intersecting polygons give "alternating" inside/outside regions Uses ray casting: runs an infinite horizontal ray (increasing x, fixed y) from the test point and counts edge crossings. Each crossing toggles inside/outside state (Jordan curve theorem). Always returns FALSE if the Polyline2D has fewer than 3 points. Boundary cases: Points exactly on edges or vertices have implementation-specific behavior. Horizontal edges are handled by the strict inequality convention (pi.Y > y) != (pj.Y > y). Points on left/bottom edges tend to be considered inside, right/top edges outside. The result may differ from checking the pl.WindingNumber 0 for boundary points.

pt : Pt

The point to test.

pl : Polyline2D

The closed Polyline2D.

Returns: bool

TRUE if the point is inside, FALSE otherwise.

Polyline2D.containsXY x y pl

Full Usage: Polyline2D.containsXY x y pl

Parameters:
    x : float - The X coordinate of the point to test.
    y : float - The Y coordinate of the point to test.
    pl : Polyline2D - The closed Polyline2D.

Returns: bool TRUE if the point is inside, FALSE otherwise.
Modifiers: inline

Tests if a point is inside the closed Polyline2D using the ray casting algorithm.

The first and last point of the Polyline2D need to be identical for correct results. Self-intersecting polygons give "alternating" inside/outside regions Uses ray casting: runs an infinite horizontal ray (increasing x, fixed y) from the test point and counts edge crossings. Each crossing toggles inside/outside state (Jordan curve theorem). Always returns FALSE if the Polyline2D has fewer than 3 points. Boundary cases: Points exactly on edges or vertices have implementation-specific behavior. Horizontal edges are handled by the strict inequality convention (pi.Y > y) != (pj.Y > y). Points on left/bottom edges tend to be considered inside, right/top edges outside. The result may differ from checking the pl.WindingNumber 0 for boundary points.

x : float

The X coordinate of the point to test.

y : float

The Y coordinate of the point to test.

pl : Polyline2D

The closed Polyline2D.

Returns: bool

TRUE if the point is inside, FALSE otherwise.

Polyline2D.createEmpty capacity

Full Usage: Polyline2D.createEmpty capacity

Parameters:
    capacity : int

Returns: Polyline2D
Modifiers: inline

Create a new empty Polyline2D without any points. But predefined capacity.

capacity : int
Returns: Polyline2D

Polyline2D.createFromBRectCCW r

Full Usage: Polyline2D.createFromBRectCCW r

Parameters:
Returns: Polyline2D

Creates a counter-clockwise Polyline2D starting at the MinX and MinY for the bounding rectangle

r : BRect
Returns: Polyline2D

Polyline2D.createFromBRectCW r

Full Usage: Polyline2D.createFromBRectCW r

Parameters:
Returns: Polyline2D

Creates a clockwise Polyline2D starting at the MinX and MinY for the bounding rectangle

r : BRect
Returns: Polyline2D

Polyline2D.createFromMembersXY xyObjs

Full Usage: Polyline2D.createFromMembersXY xyObjs

Parameters:
    xyObjs : ^T seq

Returns: Polyline2D
Modifiers: inline
Type parameters: ^T, ^a, ^b (requires (member get_X : ^T -> ^a) and (member get_Y : ^T -> ^b) and (static member op_Explicit : ^a -> Microsoft.FSharp.Core.float) and (static member op_Explicit : ^b -> Microsoft.FSharp.Core.float))

Creates a Polyline2D from a list of objects with X and Y members (uppercase).

xyObjs : ^T seq
Returns: Polyline2D

Polyline2D.createFromMembersxy xyObjs

Full Usage: Polyline2D.createFromMembersxy xyObjs

Parameters:
    xyObjs : ^T seq

Returns: Polyline2D
Modifiers: inline
Type parameters: ^T, ^a, ^b (requires (member get_x : ^T -> ^a) and (member get_y : ^T -> ^b) and (static member op_Explicit : ^a -> Microsoft.FSharp.Core.float) and (static member op_Explicit : ^b -> Microsoft.FSharp.Core.float))

Creates a Polyline2D from a list of objects with x and y members (lowercase).

xyObjs : ^T seq
Returns: Polyline2D

Polyline2D.createFromPts points

Full Usage: Polyline2D.createFromPts points

Parameters:
    points : Pt seq

Returns: Polyline2D

Create a new Polyline2D by copying over all points. This will allocate a new ResizeArray and copy all points.

points : Pt seq
Returns: Polyline2D

Polyline2D.createFromRectCCW r

Full Usage: Polyline2D.createFromRectCCW r

Parameters:
Returns: Polyline2D

Creates a counter-clockwise closed Polyline2D starting at the Origin of the Rect2D

r : Rect2D
Returns: Polyline2D

Polyline2D.createFromRectCW r

Full Usage: Polyline2D.createFromRectCW r

Parameters:
Returns: Polyline2D

Creates a clockwise closed Polyline2D starting at the Origin of the Rect2D

r : Rect2D
Returns: Polyline2D

Polyline2D.createFromXYs xys

Full Usage: Polyline2D.createFromXYs xys

Parameters:
    xys : ResizeArray<float>

Returns: Polyline2D

Create a new Polyline2D by using the provided X and Y interleaved ResizeArray directly. The buffer is shared, not copied: later changes to the ResizeArray will be reflected in the Polyline2D, and vice versa.

xys : ResizeArray<float>
Returns: Polyline2D

Polyline2D.distanceToPt pt pl

Full Usage: Polyline2D.distanceToPt pt pl

Parameters:
Returns: float
Modifiers: inline

Returns the distance of the test point to the closest point on the Polyline2D.

pt : Pt
pl : Polyline2D
Returns: float

Polyline2D.distanceToPtSigned pt pl

Full Usage: Polyline2D.distanceToPtSigned pt pl

Parameters:
Returns: float
Modifiers: inline

Calculates the shortest distance from the test point to the polyline with `DistanceToXY`, then signs that value by testing containment via the ray-casting based `ContainsXY` helper. Returns a positive distance for points that lie inside the polyline boundary and negative otherwise. For reliable results the polyline should be closed and have identical first and last vertices.

pt : Pt
pl : Polyline2D
Returns: float

Polyline2D.distanceToXY x y pl

Full Usage: Polyline2D.distanceToXY x y pl

Parameters:
Returns: float
Modifiers: inline

Returns the distance of the test point to the closest point on the Polyline2D.

x : float
y : float
pl : Polyline2D
Returns: float

Polyline2D.distanceToXYSigned x y pl

Full Usage: Polyline2D.distanceToXYSigned x y pl

Parameters:
Returns: float
Modifiers: inline

Calculates the shortest distance from the test point to the polyline with `DistanceToXY`, then signs that value by testing containment via the ray-casting based `ContainsXY` helper. Returns a positive distance for points that lie inside the polyline boundary and negative otherwise. For reliable results the polyline should be closed and have identical first and last vertices.

x : float
y : float
pl : Polyline2D
Returns: float

Polyline2D.duplicate p

Full Usage: Polyline2D.duplicate p

Parameters:
Returns: Polyline2D
Modifiers: inline

Creates a copy of the Polyline2D Same as polyline.Clone()

p : Polyline2D
Returns: Polyline2D

Polyline2D.end' p

Full Usage: Polyline2D.end' p

Parameters:
Returns: Pt
Modifiers: inline

Gets the last or end point of the Polyline2D. This is the point at index Points.Count - 1. Same as Polyline2D.LastPoint

p : Polyline2D
Returns: Pt

Polyline2D.ensureClockwise pl

Full Usage: Polyline2D.ensureClockwise pl

Parameters:
Returns: Polyline2D
Modifiers: inline

Returns a new Polyline2D that is Clockwise. It is reversed if the input is counter-clockwise. The input Polyline2D is not changed. Raises an error if the area of the Polyline2D is zero.

pl : Polyline2D
Returns: Polyline2D

Polyline2D.ensureCounterClockwise pl

Full Usage: Polyline2D.ensureCounterClockwise pl

Parameters:
Returns: Polyline2D
Modifiers: inline

Returns a new Polyline2D that is counter-clockwise. It is reversed if the input is clockwise. The input Polyline2D is not changed. Raises an error if the area of the Polyline2D is zero.

pl : Polyline2D
Returns: Polyline2D

Polyline2D.equalsExact pl1 pl2

Full Usage: Polyline2D.equalsExact pl1 pl2

Parameters:
    pl1 : Polyline2D - The first Polyline2D instance.
    pl2 : Polyline2D - The second Polyline2D instance.

Returns: bool TRUE if the two Polyline2D instances are equal, otherwise FALSE.

Tests if two Polyline2D have the same point count and if their corresponding points are exactly equal. The same instance is always equal to itself. Otherwise a NaN coordinate is never equal.

pl1 : Polyline2D

The first Polyline2D instance.

pl2 : Polyline2D

The second Polyline2D instance.

Returns: bool

TRUE if the two Polyline2D instances are equal, otherwise FALSE.

Polyline2D.equalsWithin tol pl1 pl2

Full Usage: Polyline2D.equalsWithin tol pl1 pl2

Parameters:
    tol : float - The tolerance value for comparing each coordinate.
    pl1 : Polyline2D - The first Polyline2D instance.
    pl2 : Polyline2D - The second Polyline2D instance.

Returns: bool TRUE if the two Polyline2D instances are equal within the tolerance, otherwise FALSE.

Tests if two Polyline2D have the same point count and if their corresponding points are equal within a given tolerance. The tolerance applies to the X and Y coordinates of each point separately, not to the Euclidean distance between the points. The same instance is always equal to itself. Otherwise a NaN coordinate is never equal. Use Polyline2D.equalsExact to check for an exact match.

tol : float

The tolerance value for comparing each coordinate.

pl1 : Polyline2D

The first Polyline2D instance.

pl2 : Polyline2D

The second Polyline2D instance.

Returns: bool

TRUE if the two Polyline2D instances are equal within the tolerance, otherwise FALSE.

Polyline2D.evaluateAt t pl

Full Usage: Polyline2D.evaluateAt t pl

Parameters:
Returns: Pt

Returns the point at a given parameter on the Polyline2D. The integer part of the parameter is the index of the segment that the point is on. The fractional part of the parameter is the parameter from 0.0 to 1.0 on the segment. The domain Polyline2D starts at 0.0 and ends at points.Count - 1.0 . If the parameter is within 1e-6 of an integer value, the integer value is used as parameter.

t : float
pl : Polyline2D
Returns: Pt

Polyline2D.findAllSelfIntersections pl

Full Usage: Polyline2D.findAllSelfIntersections pl

Parameters:
Returns: ResizeArray<Pt * int * int> A new list of the intersection points with the indices of the two intersecting segments, sorted by the first and then by the second segment index. The first index is always smaller than the second. The list is empty if no intersection is found or the polyline has fewer than 3 points.

Finds all self intersections in a Polyline2D in O(n²) time. Tests every pair of non-adjacent segments, with the same rules as Polyline2D.tryFindSelfIntersection: The closure joint of a closed Polyline2D is not reported as a self intersection. Two non-adjacent segments that are just touching are reported. For larger polylines with more than 100 points use the Euclid.BVH library for efficient intersection testing.

pl : Polyline2D

The polyline to search.

Returns: ResizeArray<Pt * int * int>

A new list of the intersection points with the indices of the two intersecting segments, sorted by the first and then by the second segment index. The first index is always smaller than the second. The list is empty if no intersection is found or the polyline has fewer than 3 points.

Polyline2D.findLabelPoint precision pl

Full Usage: Polyline2D.findLabelPoint precision pl

Parameters:
Returns: Pt * float

Finds a point inside a closed Polyline2D that is the farthest away from the edges of the Polyline2D. Uses the Polylabel algorithm from Mapbox. It is a highly optimized algorithm specifically designed to find the pole of inaccessibility for polygons. The point within the polygon that is farthest from the edges, often used for optimal label placement. Adaptive Precision: Can trade accuracy for speed based on your needs. The precision must be a positive number, otherwise an error is raised. Returns the best point and its distance to the polygon edge. Supplying an open polyline is allowed, but the computed "inside" still assumes the points describe a closed boundary (first and last vertices should match).

precision : float
pl : Polyline2D
Returns: Pt * float

Polyline2D.firstPoint p

Full Usage: Polyline2D.firstPoint p

Parameters:
Returns: Pt
Modifiers: inline

Gets the first point of the Polyline2D. This is the point at index 0. Same as Polyline2D.Start

p : Polyline2D
Returns: Pt

Polyline2D.firstSegment p

Full Usage: Polyline2D.firstSegment p

Parameters:
Returns: Line2D
Modifiers: inline

Gets the first segment of the Polyline2D.

p : Polyline2D
Returns: Line2D

Polyline2D.getPoint pointIndex p

Full Usage: Polyline2D.getPoint pointIndex p

Parameters:
Returns: Pt
Modifiers: inline

Gets the 2D point at the given pointIndex in the list of points. (this gets Pt(XYs.[pointIndex * 2], XYs.[pointIndex * 2 + 1]) from the internal flat list of x and y coordinates )

pointIndex : int
p : Polyline2D
Returns: Pt

Polyline2D.getSegment i p

Full Usage: Polyline2D.getSegment i p

Parameters:
Returns: Line2D
Modifiers: inline

Gets the segment at index i of the Polyline2D.

i : int
p : Polyline2D
Returns: Line2D

Polyline2D.getX pointIndex p

Full Usage: Polyline2D.getX pointIndex p

Parameters:
Returns: float
Modifiers: inline

Gets the x coordinate of the 2D point at the given pointIndex in the list of points. (this gets XYs.[pointIndex * 2] from the internal flat list of x and y coordinates )

pointIndex : int
p : Polyline2D
Returns: float

Polyline2D.getY pointIndex p

Full Usage: Polyline2D.getY pointIndex p

Parameters:
Returns: float
Modifiers: inline

Gets the y coordinate of the 2D point at the given pointIndex in the list of points. (this gets XYs.[pointIndex * 2 + 1] from the internal flat list of x and y coordinates )

pointIndex : int
p : Polyline2D
Returns: float

Polyline2D.isAlmostClosed tolerance p

Full Usage: Polyline2D.isAlmostClosed tolerance p

Parameters:
Returns: bool
Modifiers: inline

Tests if Polyline2D is closed within given tolerance. Returns FALSE if the Polyline2D has fewer than 3 points.

tolerance : float
p : Polyline2D
Returns: bool

Polyline2D.isClockwise p

Full Usage: Polyline2D.isClockwise p

Parameters:
Returns: bool
Modifiers: inline

Test if Polyline2D is Clockwise. The Polyline2D does not need to be actually closed. The signed area of the Polyline2D is calculated. If it is negative the Polyline2D is Clockwise.

p : Polyline2D
Returns: bool

Polyline2D.isClosed p

Full Usage: Polyline2D.isClosed p

Parameters:
Returns: bool
Modifiers: inline

Tests if Polyline2D start and end points are exactly the same. Returns FALSE if the Polyline2D has fewer than 3 points.

p : Polyline2D
Returns: bool

Polyline2D.isCounterClockwise p

Full Usage: Polyline2D.isCounterClockwise p

Parameters:
Returns: bool
Modifiers: inline

Test if Polyline2D is counter-clockwise. The Polyline2D does not need to be actually closed. The signed area of the Polyline2D is calculated. If it is positive the Polyline2D is counter-clockwise.

p : Polyline2D
Returns: bool

Polyline2D.iter action pl

Full Usage: Polyline2D.iter action pl

Parameters:
    action : float -> float -> unit - A function that takes the X and Y coordinates of a point.
    pl : Polyline2D - The Polyline2D to iterate over.

Modifiers: inline

Iterate over each point in the Polyline2D.

action : float -> float -> unit

A function that takes the X and Y coordinates of a point.

pl : Polyline2D

The Polyline2D to iterate over.

Polyline2D.iterLineSegments action pl

Full Usage: Polyline2D.iterLineSegments action pl

Parameters:
    action : Line2D -> unit - A function that takes a Line2D representing the segment.
    pl : Polyline2D - The Polyline2D to iterate over.

Modifiers: inline

Iterate over each segment in the Polyline2D.

action : Line2D -> unit

A function that takes a Line2D representing the segment.

pl : Polyline2D

The Polyline2D to iterate over.

Polyline2D.iterPt action pl

Full Usage: Polyline2D.iterPt action pl

Parameters:
    action : Pt -> unit - A function that takes a point.
    pl : Polyline2D - The Polyline2D to iterate over.

Iterate over each point in the Polyline2D.

action : Pt -> unit

A function that takes a point.

pl : Polyline2D

The Polyline2D to iterate over.

Polyline2D.iterSegments action pl

Full Usage: Polyline2D.iterSegments action pl

Parameters:
    action : float -> float -> float -> float -> unit - A function that takes startX, startY, endX, and endY coordinates of a segment.
    pl : Polyline2D - The Polyline2D to iterate over.

Modifiers: inline

Iterate over each segment in the Polyline2D.

action : float -> float -> float -> float -> unit

A function that takes startX, startY, endX, and endY coordinates of a segment.

pl : Polyline2D

The Polyline2D to iterate over.

Polyline2D.iteri action pl

Full Usage: Polyline2D.iteri action pl

Parameters:
    action : int -> float -> float -> unit - A function that takes the index of the X coordinate (in the flat coordinate array) and the X and Y coordinates of a point.
    pl : Polyline2D - The Polyline2D to iterate over.

Iterate over each point in the Polyline2D with index.

action : int -> float -> float -> unit

A function that takes the index of the X coordinate (in the flat coordinate array) and the X and Y coordinates of a point.

pl : Polyline2D

The Polyline2D to iterate over.

Polyline2D.iteriPt action pl

Full Usage: Polyline2D.iteriPt action pl

Parameters:
    action : int -> Pt -> unit - A function that takes the pointIndex of the point ( = array index/2) and the point itself.
    pl : Polyline2D - The Polyline2D to iterate over.

Iterate over each point in the Polyline2D with index.

action : int -> Pt -> unit

A function that takes the pointIndex of the point ( = array index/2) and the point itself.

pl : Polyline2D

The Polyline2D to iterate over.

Polyline2D.lastPoint p

Full Usage: Polyline2D.lastPoint p

Parameters:
Returns: Pt
Modifiers: inline

Gets the last point of the Polyline2D. This is the point at index Points.Count - 1. Same as Polyline2D.End

p : Polyline2D
Returns: Pt

Polyline2D.lastSegment p

Full Usage: Polyline2D.lastSegment p

Parameters:
Returns: Line2D
Modifiers: inline

Gets the last segment of the Polyline2D.

p : Polyline2D
Returns: Line2D

Polyline2D.length p

Full Usage: Polyline2D.length p

Parameters:
Returns: float
Modifiers: inline

Gets the length of the Polyline2D. The sum of the lengths of all segments. Returns 0.0 if there are fewer than 2 points.

p : Polyline2D
Returns: float

Polyline2D.map mapping pl

Full Usage: Polyline2D.map mapping pl

Parameters:
    mapping : float -> float -> Pt - A function that takes the X and Y coordinates of a point and returns a new point.
    pl : Polyline2D - The Polyline2D to map over.

Returns: Polyline2D A new Polyline2D with the mapped points.

Apply a mapping function to each point in the Polyline2D. Returns new Polyline2D.

mapping : float -> float -> Pt

A function that takes the X and Y coordinates of a point and returns a new point.

pl : Polyline2D

The Polyline2D to map over.

Returns: Polyline2D

A new Polyline2D with the mapped points.

Polyline2D.mapPt mapping pl

Full Usage: Polyline2D.mapPt mapping pl

Parameters:
    mapping : Pt -> Pt - A function that takes a point and returns a new point.
    pl : Polyline2D - The Polyline2D to map over.

Returns: Polyline2D A new Polyline2D with the mapped points.

Apply a mapping function to each point in the Polyline2D. Returns new Polyline2D.

mapping : Pt -> Pt

A function that takes a point and returns a new point.

pl : Polyline2D

The Polyline2D to map over.

Returns: Polyline2D

A new Polyline2D with the mapped points.

Polyline2D.mapi mapping pl

Full Usage: Polyline2D.mapi mapping pl

Parameters:
    mapping : int -> float -> float -> Pt - A function that takes the index of the X coordinate (in the flat coordinate array) and the X and Y coordinates of a point and returns a new point.
    pl : Polyline2D - The Polyline2D to map over.

Returns: Polyline2D A new Polyline2D with the mapped points.

Apply a mapping function to each point in the Polyline2D with index. Returns new Polyline2D.

mapping : int -> float -> float -> Pt

A function that takes the index of the X coordinate (in the flat coordinate array) and the X and Y coordinates of a point and returns a new point.

pl : Polyline2D

The Polyline2D to map over.

Returns: Polyline2D

A new Polyline2D with the mapped points.

Polyline2D.mapiPt mapping pl

Full Usage: Polyline2D.mapiPt mapping pl

Parameters:
    mapping : int -> Pt -> Pt - A function that takes the pointIndex of the point ( = array index/2) and the point itself, and returns a new point.
    pl : Polyline2D - The Polyline2D to map over.

Returns: Polyline2D A new Polyline2D with the mapped points.

Apply a mapping function to each point in the Polyline2D with the pointIndex (not the index into the flat coordinate array). Returns new Polyline2D.

mapping : int -> Pt -> Pt

A function that takes the pointIndex of the point ( = array index/2) and the point itself, and returns a new point.

pl : Polyline2D

The Polyline2D to map over.

Returns: Polyline2D

A new Polyline2D with the mapped points.

Polyline2D.move v pl

Full Usage: Polyline2D.move v pl

Parameters:
Returns: Polyline2D

Returns a new Polyline2D moved by a vector. The input Polyline2D is not changed.

v : Vc
pl : Polyline2D
Returns: Polyline2D

Polyline2D.movePoint pointIndex v p

Full Usage: Polyline2D.movePoint pointIndex v p

Parameters:
    pointIndex : int - The index of the point to move. Must be between 0 and PointCount - 1.
    v : Vc - The vector to move the point by.
    p : Polyline2D - The Polyline2D to change.

Modifiers: inline

Moves the 2D point at the given pointIndex in place by a vector. NOTE: moving the first or last point on a closed Polyline2D opens it. Use Polyline2D.movePointPreservingClosure to keep it closed.

pointIndex : int

The index of the point to move. Must be between 0 and PointCount - 1.

v : Vc

The vector to move the point by.

p : Polyline2D

The Polyline2D to change.

Polyline2D.movePointPreservingClosure pointIndex v p

Full Usage: Polyline2D.movePointPreservingClosure pointIndex v p

Parameters:
    pointIndex : int - The index of the point to move. Must be between 0 and PointCount - 1.
    v : Vc - The vector to move the point by.
    p : Polyline2D - The Polyline2D to change.

Modifiers: inline

Moves the 2D point at the given pointIndex in place by a vector. On a closed Polyline2D, moving the first or last point moves both, so it stays closed.

pointIndex : int

The index of the point to move. Must be between 0 and PointCount - 1.

v : Vc

The vector to move the point by.

p : Polyline2D

The Polyline2D to change.

Polyline2D.moveX distance pl

Full Usage: Polyline2D.moveX distance pl

Parameters:
Returns: Polyline2D

Returns a new Polyline2D moved by a given distance in X direction. The input Polyline2D is not changed.

distance : float
pl : Polyline2D
Returns: Polyline2D

Polyline2D.moveXY pointIndex x y p

Full Usage: Polyline2D.moveXY pointIndex x y p

Parameters:
    pointIndex : int - The index of the point to move. Must be between 0 and PointCount - 1.
    x : float - The distance to move the point in X direction.
    y : float - The distance to move the point in Y direction.
    p : Polyline2D - The Polyline2D to change.

Modifiers: inline

Moves the 2D point at the given pointIndex in place by the given x and y distances. NOTE: moving the first or last point on a closed Polyline2D opens it. Use Polyline2D.moveXYPreservingClosure to keep it closed.

pointIndex : int

The index of the point to move. Must be between 0 and PointCount - 1.

x : float

The distance to move the point in X direction.

y : float

The distance to move the point in Y direction.

p : Polyline2D

The Polyline2D to change.

Polyline2D.moveXYPreservingClosure pointIndex x y p

Full Usage: Polyline2D.moveXYPreservingClosure pointIndex x y p

Parameters:
    pointIndex : int - The index of the point to move. Must be between 0 and PointCount - 1.
    x : float - The distance to move the point in X direction.
    y : float - The distance to move the point in Y direction.
    p : Polyline2D - The Polyline2D to change.

Modifiers: inline

Moves the 2D point at the given pointIndex in place by the given x and y distances. On a closed Polyline2D, moving the first or last point moves both, so it stays closed.

pointIndex : int

The index of the point to move. Must be between 0 and PointCount - 1.

x : float

The distance to move the point in X direction.

y : float

The distance to move the point in Y direction.

p : Polyline2D

The Polyline2D to change.

Polyline2D.moveY distance pl

Full Usage: Polyline2D.moveY distance pl

Parameters:
Returns: Polyline2D

Returns a new Polyline2D moved by a given distance in Y direction. The input Polyline2D is not changed.

distance : float
pl : Polyline2D
Returns: Polyline2D

Polyline2D.offset offsetDistance pl

Full Usage: Polyline2D.offset offsetDistance pl

Parameters:
Returns: Polyline2D
Modifiers: inline

Offsets a Polyline in 2D space by finding the local offset in each corner. Auto detects if given points are from a closed Polyline (first point = last point) and loops them. Raises an Exception on duplicate points and 180 degree U-Turns. Positive offset distances are always towards the inside of the polyline, negative offset distances to the outside. Uses the default settings of Polyline2D.offsetCustom. Use Polyline2D.offsetCustom to set them.

offsetDistance : float
pl : Polyline2D
Returns: Polyline2D

Polyline2D.offsetCustom (polyLine, constantOffsetDistance, ?loop, ?checkOrientation, ?uTurnBehavior, ?useUTurnBehaviorAbove)

Full Usage: Polyline2D.offsetCustom (polyLine, constantOffsetDistance, ?loop, ?checkOrientation, ?uTurnBehavior, ?useUTurnBehaviorAbove)

Parameters:
    polyLine : Polyline2D - A 2D Polyline, open or closed.
    constantOffsetDistance : float - The offset distance for all segments of the polyline. A positive distance offset to the inside of the polyline. A negative distance offset to the outside of the polyline.
    ?loop : bool - bool, Optional (FALSE). Set to TRUE to explicitly consider last point and first point to be from a closed loop, even if they are not at the same location.
    ?checkOrientation : bool - bool, Optional(TRUE). By default the algorithm always checks if the polyline is clockwise or counter-clockwise. So that positive offset distances are always towards the inside of the polyline. Set this parameter to FALSE if you want to skip the orientation check. Clockwise polylines will offset to the outside, counter-clockwise polylines to the inside.
    ?uTurnBehavior : UTurn - Optional. Default value: `Offset2D.UTurn.Fail`. What to do at a 180 degree U-turn? Fail, Chamfer with two points, Use179 or Skip the point.
    ?useUTurnBehaviorAbove : MeasureProduct<cosine, MeasureOne> - Optional. Default value: `Cosine.``175.0`` `. The angle between normals after which, instead of a normal miter, the joint is chamfered by adding an extra point.

Returns: Polyline2D A new 2D polyline.

Offsets a Polyline in 2D space by finding the local offset in each corner. Auto detects if given points are from a closed Polyline (first point = last point) and loops them. By default this function raises an Exception on duplicate points, 180 degree U-Turns. But this can be configured with optional parameters.

polyLine : Polyline2D

A 2D Polyline, open or closed.

constantOffsetDistance : float

The offset distance for all segments of the polyline. A positive distance offset to the inside of the polyline. A negative distance offset to the outside of the polyline.

?loop : bool

bool, Optional (FALSE). Set to TRUE to explicitly consider last point and first point to be from a closed loop, even if they are not at the same location.

?checkOrientation : bool

bool, Optional(TRUE). By default the algorithm always checks if the polyline is clockwise or counter-clockwise. So that positive offset distances are always towards the inside of the polyline. Set this parameter to FALSE if you want to skip the orientation check. Clockwise polylines will offset to the outside, counter-clockwise polylines to the inside.

?uTurnBehavior : UTurn

Optional. Default value: `Offset2D.UTurn.Fail`. What to do at a 180 degree U-turn? Fail, Chamfer with two points, Use179 or Skip the point.

?useUTurnBehaviorAbove : MeasureProduct<cosine, MeasureOne>

Optional. Default value: `Cosine.``175.0`` `. The angle between normals after which, instead of a normal miter, the joint is chamfered by adding an extra point.

Returns: Polyline2D

A new 2D polyline.

Polyline2D.offsetVariable multipleOffsetDistances pl

Full Usage: Polyline2D.offsetVariable multipleOffsetDistances pl

Parameters:
    multipleOffsetDistances : IList<float> - The parallel offset distances for each segment of the polyline. A positive distance offsets inwards in corners, a negative offset outwards. This list of distances must have one item less than number of points in the polyline.
    pl : Polyline2D - A 2D Polyline, open or closed.

Returns: Polyline2D A new 2D polyline.

Offsets a Polyline in 2D space by finding the local offset in each corner, with one distance per segment. Auto detects if given points are from a closed Polyline (first point = last point) and loops them. Raises an Exception on duplicate points, 180 degree U-Turns, and variable distances at collinear segments. Uses the default settings of Polyline2D.offsetVariableCustom. Use Polyline2D.offsetVariableCustom to set them.

multipleOffsetDistances : IList<float>

The parallel offset distances for each segment of the polyline. A positive distance offsets inwards in corners, a negative offset outwards. This list of distances must have one item less than number of points in the polyline.

pl : Polyline2D

A 2D Polyline, open or closed.

Returns: Polyline2D

A new 2D polyline.

Polyline2D.offsetVariableCustom (polyLine, multipleOffsetDistances, ?loop, ?checkOrientation, ?varDistParallelBehavior, ?uTurnBehavior, ?useVarDistParallelBehaviorBelow, ?useUTurnBehaviorAbove)

Full Usage: Polyline2D.offsetVariableCustom (polyLine, multipleOffsetDistances, ?loop, ?checkOrientation, ?varDistParallelBehavior, ?uTurnBehavior, ?useVarDistParallelBehaviorBelow, ?useUTurnBehaviorAbove)

Parameters:
    polyLine : Polyline2D - A 2D Polyline, open or closed.
    multipleOffsetDistances : IList<float> - The parallel offset distances for each segment of the polyline. A positive distance offsets inwards in corners, a negative offset outwards. For open and closed polylines this list of distances must have one item less than number of points in the polyline. Except if the polyline is open and the loop parameter is set to TRUE. Then points and distances list shall have the same count.
    ?loop : bool - bool, Optional (FALSE). Set to TRUE to explicitly consider last point and first point to be from a closed loop, even if they are not at the same location.
    ?checkOrientation : bool - bool, Optional(TRUE). By default the algorithm always checks if the polyline is clockwise or counter-clockwise. So that positive offset distances are always towards the inside of the polyline. Set this parameter to FALSE if you want to skip the orientation check. Clockwise polylines will offset to the outside, counter-clockwise polylines to the inside.
    ?varDistParallelBehavior : VarDistParallel - Optional. Default value: `Offset2D.VarDistParallel.Fail`. What to do with collinear segments below 'useVarDistParallelBehaviorBelow' degrees when offset distances are different too.
    ?uTurnBehavior : UTurn - Optional. Default value: `Offset2D.UTurn.Fail`. What to do at a 180 degree U-turn? Fail, Chamfer with two points, Use179 or Skip the point.
    ?useVarDistParallelBehaviorBelow : MeasureProduct<cosine, MeasureOne> - Optional. Default value: `Cosine.``2.5`` `. The angle between normals below which points are considered collinear and VarDistParallelBehavior is applied if distances are not the same. Unless the polyline turned by more than this angle since the last point that was offset exactly, then the point is offset where the offset lines meet, so that an arc keeps its shape.
    ?useUTurnBehaviorAbove : MeasureProduct<cosine, MeasureOne> - Optional. Default value: `Cosine.``175.0`` `. The angle between normals after which, instead of a normal miter, the joint is chamfered by adding an extra point.

Returns: Polyline2D A new 2D polyline.

Offsets a Polyline in 2D space by finding the local offset in each corner. Auto detects if given points are from a closed Polyline (first point = last point) and loops them. By default this function raises an Exception on duplicate points, 180 degree U-Turns, and variable distances at collinear segments. But this can be configured with optional parameters.

polyLine : Polyline2D

A 2D Polyline, open or closed.

multipleOffsetDistances : IList<float>

The parallel offset distances for each segment of the polyline. A positive distance offsets inwards in corners, a negative offset outwards. For open and closed polylines this list of distances must have one item less than number of points in the polyline. Except if the polyline is open and the loop parameter is set to TRUE. Then points and distances list shall have the same count.

?loop : bool

bool, Optional (FALSE). Set to TRUE to explicitly consider last point and first point to be from a closed loop, even if they are not at the same location.

?checkOrientation : bool

bool, Optional(TRUE). By default the algorithm always checks if the polyline is clockwise or counter-clockwise. So that positive offset distances are always towards the inside of the polyline. Set this parameter to FALSE if you want to skip the orientation check. Clockwise polylines will offset to the outside, counter-clockwise polylines to the inside.

?varDistParallelBehavior : VarDistParallel

Optional. Default value: `Offset2D.VarDistParallel.Fail`. What to do with collinear segments below 'useVarDistParallelBehaviorBelow' degrees when offset distances are different too.

?uTurnBehavior : UTurn

Optional. Default value: `Offset2D.UTurn.Fail`. What to do at a 180 degree U-turn? Fail, Chamfer with two points, Use179 or Skip the point.

?useVarDistParallelBehaviorBelow : MeasureProduct<cosine, MeasureOne>

Optional. Default value: `Cosine.``2.5`` `. The angle between normals below which points are considered collinear and VarDistParallelBehavior is applied if distances are not the same. Unless the polyline turned by more than this angle since the last point that was offset exactly, then the point is offset where the offset lines meet, so that an arc keeps its shape.

?useUTurnBehaviorAbove : MeasureProduct<cosine, MeasureOne>

Optional. Default value: `Cosine.``175.0`` `. The angle between normals after which, instead of a normal miter, the joint is chamfered by adding an extra point.

Returns: Polyline2D

A new 2D polyline.

Polyline2D.pointCount p

Full Usage: Polyline2D.pointCount p

Parameters:
Returns: int
Modifiers: inline

Gets the number of points in the Polyline2D.

p : Polyline2D
Returns: int

Polyline2D.removeDuplicateAndCollinearPoints angleTolerance distanceTolerance pl

Full Usage: Polyline2D.removeDuplicateAndCollinearPoints angleTolerance distanceTolerance pl

Parameters:
Returns: Polyline2D

Returns a new Polyline2D with consecutive duplicate points and collinear points removed, within given tolerances. The input Polyline2D is not changed. Use p.RemoveDuplicateAndCollinearPoints to remove the points in place. This algorithm allows the last and first point to be identical if the Polyline2D is closed. Collinear points are removed when the angle between segments is smaller than the cosine threshold (e.g. cosine of 0.5 degrees ). If the Polyline2D is closed and starts and ends with collinear segments, the first point is replaced with the last non-collinear point. So the joint of the loop is now moved to the last non-collinear point. So that there are no collinear segments even between start and end. Raises an error if all points are within the distanceTolerance of the first point.

angleTolerance : float<MeasureProduct<cosine, MeasureOne>>
distanceTolerance : float
pl : Polyline2D
Returns: Polyline2D

Polyline2D.removeDuplicatePoints distanceTolerance pl

Full Usage: Polyline2D.removeDuplicatePoints distanceTolerance pl

Parameters:
    distanceTolerance : float - The distance within which points are considered duplicates.
    pl : Polyline2D - A 2D Polyline, open or closed.

Returns: Polyline2D A new Polyline2D. Use p.RemoveDuplicatePoints to remove the points in place.

Returns a new Polyline2D with consecutive duplicate points removed, within a given tolerance. The input Polyline2D is not changed.

From a cluster of points that are closer than the distanceTolerance, only the first point is kept. Use 'Polyline2D.removeDuplicatePointsFaithfully' if you want to keep the edges in their position by re-intersecting segments. The position of start and end point is NOT changed. Use Polyline2D.close to ensure start and end point are identical.

distanceTolerance : float

The distance within which points are considered duplicates.

pl : Polyline2D

A 2D Polyline, open or closed.

Returns: Polyline2D

A new Polyline2D. Use p.RemoveDuplicatePoints to remove the points in place.

Polyline2D.removeDuplicatePointsAndReport distanceTolerance pl

Full Usage: Polyline2D.removeDuplicatePointsAndReport distanceTolerance pl

Parameters:
    distanceTolerance : float - The distance within which points are considered duplicates.
    pl : Polyline2D - A 2D Polyline, open or closed.

Returns: Polyline2D * ResizeArray<Pt> A tuple of the new Polyline2D and the removed duplicate points, with consecutive identical entries listed once per run. The list of removed points is empty if no duplicates were found. Use p.RemoveDuplicatePointsAndReport to remove the points in place.

Returns a new Polyline2D with consecutive duplicate points removed, within a given tolerance, and the removed points. Same as 'Polyline2D.removeDuplicatePoints', but also reports the points that were removed. The input Polyline2D is not changed.

distanceTolerance : float

The distance within which points are considered duplicates.

pl : Polyline2D

A 2D Polyline, open or closed.

Returns: Polyline2D * ResizeArray<Pt>

A tuple of the new Polyline2D and the removed duplicate points, with consecutive identical entries listed once per run. The list of removed points is empty if no duplicates were found. Use p.RemoveDuplicatePointsAndReport to remove the points in place.

Polyline2D.removeDuplicatePointsFaithfully distanceTolerance pl

Full Usage: Polyline2D.removeDuplicatePointsFaithfully distanceTolerance pl

Parameters:
    distanceTolerance : float - The distance within which points are considered duplicates.
    pl : Polyline2D - A 2D Polyline, open or closed.

Returns: Polyline2D A new Polyline2D. Use p.RemoveDuplicatePointsFaithfully to remove the points in place.

Returns a new Polyline2D with consecutive duplicate points removed, within a given tolerance. The input Polyline2D is not changed.

This algorithm keeps edges in their position by re-intersecting segments if points are closer than the distanceTolerance but not identical. The position of start and end point is NOT changed. Use Polyline2D.close to ensure start and end point are identical.

distanceTolerance : float

The distance within which points are considered duplicates.

pl : Polyline2D

A 2D Polyline, open or closed.

Returns: Polyline2D

A new Polyline2D. Use p.RemoveDuplicatePointsFaithfully to remove the points in place.

Polyline2D.removeUTurns minCos polyLine

Full Usage: Polyline2D.removeUTurns minCos polyLine

Parameters:
    minCos : float<MeasureProduct<cosine, MeasureOne>> - The angle between segments so that they are considered a U-turn. For example, for 179.9 degrees use 'Cosine.``179.9``'.
    polyLine : Polyline2D - A 2D Polyline, open or closed.

Returns: Polyline2D A new Polyline2D. Use p.RemoveUTurns to remove the U-turns in place.

Returns a new Polyline2D with simple sharp U-Turns removed. The input Polyline2D is not changed.

For nested U-turns and collinear points in U-turns segments use 'removeUTurnsDeeply'.

minCos : float<MeasureProduct<cosine, MeasureOne>>

The angle between segments so that they are considered a U-turn. For example, for 179.9 degrees use 'Cosine.``179.9``'.

polyLine : Polyline2D

A 2D Polyline, open or closed.

Returns: Polyline2D

A new Polyline2D. Use p.RemoveUTurns to remove the U-turns in place.

Polyline2D.removeUTurnsDeeply minCos polyLine

Full Usage: Polyline2D.removeUTurnsDeeply minCos polyLine

Parameters:
    minCos : float<MeasureProduct<cosine, MeasureOne>> - The angle between segments so that they are considered a U-turn. For example, for 179.9 degrees use 'Cosine.``179.9``'.
    polyLine : Polyline2D - A 2D Polyline, open or closed.

Returns: Polyline2D A new Polyline2D. Use p.RemoveUTurnsDeeply to remove the U-turns in place.

Returns a new Polyline2D with all sharp U-Turns removed, recursively until no more U-turns are present. The input Polyline2D is not changed. Use this function when you have nested U-turns and collinear points in U-turns segments.

minCos : float<MeasureProduct<cosine, MeasureOne>>

The angle between segments so that they are considered a U-turn. For example, for 179.9 degrees use 'Cosine.``179.9``'.

polyLine : Polyline2D

A 2D Polyline, open or closed.

Returns: Polyline2D

A new Polyline2D. Use p.RemoveUTurnsDeeply to remove the U-turns in place.

Polyline2D.reverse p

Full Usage: Polyline2D.reverse p

Parameters:
Returns: Polyline2D

Returns a new Polyline2D with the order of the points reversed. The input Polyline2D is not changed. Use p.Reverse() to reverse in place.

p : Polyline2D
Returns: Polyline2D

Polyline2D.rotate r pl

Full Usage: Polyline2D.rotate r pl

Parameters:
Returns: Polyline2D

Returns a new Polyline2D rotated around the world origin by a Rotation2D. The input Polyline2D is not changed.

r : Rotation2D
pl : Polyline2D
Returns: Polyline2D

Polyline2D.rotateAround cen r pl

Full Usage: Polyline2D.rotateAround cen r pl

Parameters:
    cen : Pt - The center point of the rotation.
    r : Rotation2D - The rotation to apply.
    pl : Polyline2D - The Polyline2D to rotate. It is not changed.

Returns: Polyline2D A new Polyline2D. Use p.RotateAround to rotate in place.

Returns a new Polyline2D rotated counter-clockwise around a given center point by a Rotation2D.

cen : Pt

The center point of the rotation.

r : Rotation2D

The rotation to apply.

pl : Polyline2D

The Polyline2D to rotate. It is not changed.

Returns: Polyline2D

A new Polyline2D. Use p.RotateAround to rotate in place.

Polyline2D.rotateDegrees angDegree pl

Full Usage: Polyline2D.rotateDegrees angDegree pl

Parameters:
    angDegree : float - The rotation angle in degrees.
    pl : Polyline2D - The Polyline2D to rotate. It is not changed.

Returns: Polyline2D A new Polyline2D. Use p.RotateDegrees to rotate in place.

Returns a new Polyline2D rotated counter-clockwise around the world origin by an angle in degrees.

For better performance precompute the Rotation2D struct and rotate with Polyline2D.rotate.

angDegree : float

The rotation angle in degrees.

pl : Polyline2D

The Polyline2D to rotate. It is not changed.

Returns: Polyline2D

A new Polyline2D. Use p.RotateDegrees to rotate in place.

Polyline2D.rotateDegreesAround cen angDegree pl

Full Usage: Polyline2D.rotateDegreesAround cen angDegree pl

Parameters:
    cen : Pt - The center point of the rotation.
    angDegree : float - The rotation angle in degrees.
    pl : Polyline2D - The Polyline2D to rotate. It is not changed.

Returns: Polyline2D A new Polyline2D. Use p.RotateDegreesAround to rotate in place.

Returns a new Polyline2D rotated counter-clockwise around a given center point by an angle in degrees.

cen : Pt

The center point of the rotation.

angDegree : float

The rotation angle in degrees.

pl : Polyline2D

The Polyline2D to rotate. It is not changed.

Returns: Polyline2D

A new Polyline2D. Use p.RotateDegreesAround to rotate in place.

Polyline2D.rotateRadians angRadians pl

Full Usage: Polyline2D.rotateRadians angRadians pl

Parameters:
    angRadians : float - The rotation angle in radians.
    pl : Polyline2D - The Polyline2D to rotate. It is not changed.

Returns: Polyline2D A new Polyline2D. Use p.RotateRadians to rotate in place.

Returns a new Polyline2D rotated counter-clockwise around the world origin by an angle in radians.

For better performance precompute the Rotation2D struct and rotate with Polyline2D.rotate.

angRadians : float

The rotation angle in radians.

pl : Polyline2D

The Polyline2D to rotate. It is not changed.

Returns: Polyline2D

A new Polyline2D. Use p.RotateRadians to rotate in place.

Polyline2D.rotateRadiansAround cen angRadians pl

Full Usage: Polyline2D.rotateRadiansAround cen angRadians pl

Parameters:
    cen : Pt - The center point of the rotation.
    angRadians : float - The rotation angle in radians.
    pl : Polyline2D - The Polyline2D to rotate. It is not changed.

Returns: Polyline2D A new Polyline2D. Use p.RotateRadiansAround to rotate in place.

Returns a new Polyline2D rotated counter-clockwise around a given center point by an angle in radians.

cen : Pt

The center point of the rotation.

angRadians : float

The rotation angle in radians.

pl : Polyline2D

The Polyline2D to rotate. It is not changed.

Returns: Polyline2D

A new Polyline2D. Use p.RotateRadiansAround to rotate in place.

Polyline2D.scale factor pl

Full Usage: Polyline2D.scale factor pl

Parameters:
Returns: Polyline2D

Returns a new Polyline2D scaled by a given factor. The input Polyline2D is not changed. Scale center is World Origin 0,0

factor : float
pl : Polyline2D
Returns: Polyline2D

Polyline2D.scaleOn cen factor pl

Full Usage: Polyline2D.scaleOn cen factor pl

Parameters:
    cen : Pt - The center point of the scaling.
    factor : float - The scale factor.
    pl : Polyline2D - The Polyline2D to scale. It is not changed.

Returns: Polyline2D A new Polyline2D. Use p.ScaleOn to scale in place.
Modifiers: inline

Returns a new Polyline2D scaled by a given factor around a given center point.

cen : Pt

The center point of the scaling.

factor : float

The scale factor.

pl : Polyline2D

The Polyline2D to scale. It is not changed.

Returns: Polyline2D

A new Polyline2D. Use p.ScaleOn to scale in place.

Polyline2D.secondLastPoint p

Full Usage: Polyline2D.secondLastPoint p

Parameters:
Returns: Pt
Modifiers: inline

Gets the second last point of the Polyline2D.

p : Polyline2D
Returns: Pt

Polyline2D.secondPoint p

Full Usage: Polyline2D.secondPoint p

Parameters:
Returns: Pt
Modifiers: inline

Gets the second point of the Polyline2D. This is the point at index 1.

p : Polyline2D
Returns: Pt

Polyline2D.segmentCount p

Full Usage: Polyline2D.segmentCount p

Parameters:
Returns: int
Modifiers: inline

Gets the number of segments in the Polyline2D. This is the point count minus one, but never negative.

p : Polyline2D
Returns: int

Polyline2D.segmentVectors p

Full Usage: Polyline2D.segmentVectors p

Parameters:
Returns: ResizeArray<Vc>
Modifiers: inline

Returns the line vectors of all segments of the Polyline2D as a list of Vc. The length of the list is one less than the point count.

p : Polyline2D
Returns: ResizeArray<Vc>

Polyline2D.segmentVectorsXY p

Full Usage: Polyline2D.segmentVectorsXY p

Parameters:
Returns: ResizeArray<float>
Modifiers: inline

Returns the line vectors of all segments of the Polyline2D as a flat list of x and y components. The length of the list is 2 less than the xys count, so one less vector than points in the polyline.

p : Polyline2D
Returns: ResizeArray<float>

Polyline2D.segments p

Full Usage: Polyline2D.segments p

Parameters:
Returns: ResizeArray<Line2D>
Modifiers: inline

Returns all segments of the Polyline2D as a list of Line2D.

p : Polyline2D
Returns: ResizeArray<Line2D>

Polyline2D.setPoint pointIndex pt p

Full Usage: Polyline2D.setPoint pointIndex pt p

Parameters:
Modifiers: inline

Sets the 2D point at the given pointIndex in the list of points. (this sets XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int
pt : Pt
p : Polyline2D

Polyline2D.setPointPreservingClosure pointIndex pt p

Full Usage: Polyline2D.setPointPreservingClosure pointIndex pt p

Parameters:
Modifiers: inline

Sets the 2D point at the given pointIndex in the list of points. On a closed Polyline2D, setting the first or last point will set both to the same point. Raises an error if the pointIndex is out of range. (this sets XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int
pt : Pt
p : Polyline2D

Polyline2D.setXY pointIndex x y p

Full Usage: Polyline2D.setXY pointIndex x y p

Parameters:
    pointIndex : int
    x : float
    y : float
    p : Polyline2D

Modifiers: inline

Sets the x and y coordinates of the 2D point at the given pointIndex in the list of points. NOTE: setting the first or last point on a closed Polyline2D might open it. (this sets XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int
x : float
y : float
p : Polyline2D

Polyline2D.setXYPreservingClosure pointIndex x y p

Full Usage: Polyline2D.setXYPreservingClosure pointIndex x y p

Parameters:
    pointIndex : int
    x : float
    y : float
    p : Polyline2D

Modifiers: inline

Sets the x and y coordinates of the 2D point at the given pointIndex in the list of points. On a closed Polyline2D, setting the first or last point will set both to the same point. Raises an error if the pointIndex is out of range. (this sets XYs.[pointIndex * 2] and XYs.[pointIndex * 2 + 1] in the internal flat list of x and y coordinates )

pointIndex : int
x : float
y : float
p : Polyline2D

Polyline2D.signedArea p

Full Usage: Polyline2D.signedArea p

Parameters:
Returns: float
Modifiers: inline

Calculates the signed area of the Polyline2D. If it is positive the Polyline2D is counter-clockwise. Polyline does not need to be exactly closed. The segment from the last point to the first point is included in the area calculation. For self-intersecting Polylines the result is invalid. Raises an error on an empty Polyline2D.

p : Polyline2D
Returns: float

Polyline2D.start p

Full Usage: Polyline2D.start p

Parameters:
Returns: Pt
Modifiers: inline

Gets the first point of the Polyline2D. This is the point at index 0. Same as Polyline2D.FirstPoint

p : Polyline2D
Returns: Pt

Polyline2D.subPolyline a b pl

Full Usage: Polyline2D.subPolyline a b pl

Parameters:
Returns: Polyline2D

Returns new Polyline2D from point at Parameter a to point at Parameter b. If 'a' is bigger than 'b' then the new Polyline2D is in opposite direction. If the start parameter is less than 1e-4 below the next integer it snaps up to that vertex. If the end parameter is less than 1e-4 above the previous integer it snaps down to that vertex. Raises an error if a parameter is outside the domain of the Polyline2D (0.0 to points.Count - 1.0).

a : float
b : float
pl : Polyline2D
Returns: Polyline2D

Polyline2D.tryFind condition pl

Full Usage: Polyline2D.tryFind condition pl

Parameters:
    condition : float -> float -> bool - A function that takes the X and Y coordinates of a point and returns a boolean indicating whether the condition is satisfied.
    pl : Polyline2D - The Polyline2D to search through.

Returns: Pt voption ValueSome(Pt) if a point satisfying the condition is found, otherwise ValueNone.
Modifiers: inline

Find the first point in the Polyline2D that satisfies a given condition. Returns ValueSome(point) if found, otherwise ValueNone.

condition : float -> float -> bool

A function that takes the X and Y coordinates of a point and returns a boolean indicating whether the condition is satisfied.

pl : Polyline2D

The Polyline2D to search through.

Returns: Pt voption

ValueSome(Pt) if a point satisfying the condition is found, otherwise ValueNone.

Polyline2D.tryFindIndex condition pl

Full Usage: Polyline2D.tryFindIndex condition pl

Parameters:
    condition : float -> float -> bool - A function that takes the X and Y coordinates of a point and returns a boolean indicating whether the condition is satisfied.
    pl : Polyline2D - The Polyline2D to search through.

Returns: int voption ValueSome(index of x) the index of the x value in the polyline's flat array if found, otherwise ValueNone.
Modifiers: inline

Find the index of the first point in the Polyline2D that satisfies a given condition. Returns ValueSome(index) if found, otherwise ValueNone.

condition : float -> float -> bool

A function that takes the X and Y coordinates of a point and returns a boolean indicating whether the condition is satisfied.

pl : Polyline2D

The Polyline2D to search through.

Returns: int voption

ValueSome(index of x) the index of the x value in the polyline's flat array if found, otherwise ValueNone.

Polyline2D.tryFindLast condition pl

Full Usage: Polyline2D.tryFindLast condition pl

Parameters:
    condition : float -> float -> bool - A function that takes the X and Y coordinates of a point and returns a boolean indicating whether the condition is satisfied.
    pl : Polyline2D - The Polyline2D to search through.

Returns: Pt voption ValueSome(Pt) if a point satisfying the condition is found, otherwise ValueNone.
Modifiers: inline

Find the last point in the Polyline2D that satisfies a given condition. Returns ValueSome(point) if found, otherwise ValueNone.

condition : float -> float -> bool

A function that takes the X and Y coordinates of a point and returns a boolean indicating whether the condition is satisfied.

pl : Polyline2D

The Polyline2D to search through.

Returns: Pt voption

ValueSome(Pt) if a point satisfying the condition is found, otherwise ValueNone.

Polyline2D.tryFindLastIndex condition pl

Full Usage: Polyline2D.tryFindLastIndex condition pl

Parameters:
    condition : float -> float -> bool - A function that takes the X and Y coordinates of a point and returns a boolean indicating whether the condition is satisfied.
    pl : Polyline2D - The Polyline2D to search through.

Returns: int voption ValueSome(index of x) the index of the x value in the polyline's flat array if found, otherwise ValueNone.
Modifiers: inline

Find the index of the last point in the Polyline2D that satisfies a given condition. Returns ValueSome(index) if found, otherwise ValueNone.

condition : float -> float -> bool

A function that takes the X and Y coordinates of a point and returns a boolean indicating whether the condition is satisfied.

pl : Polyline2D

The Polyline2D to search through.

Returns: int voption

ValueSome(index of x) the index of the x value in the polyline's flat array if found, otherwise ValueNone.

Polyline2D.tryFindSelfIntersection pl

Full Usage: Polyline2D.tryFindSelfIntersection pl

Parameters:
Returns: (Pt * int * int) voption

Tries to find a self intersection in Polyline2D. A closed Polyline2D, is not reported as a self intersection. Also returns ValueSome if two non-adjacent segments are just touching. If found returns the first intersection point and the indices of the two segments that intersect. If no intersection is found returns ValueNone. Returns ValueNone for Polylines with fewer than 3 points (less than two segments). This is an iterative O(n^2) algorithm. For larger polylines with more than 100 points use Polyline2D.tryFindSelfIntersectionWithBvh from the Euclid.BVH library for efficient intersection testing.

pl : Polyline2D
Returns: (Pt * int * int) voption

Polyline2D.windingNumber point pl

Full Usage: Polyline2D.windingNumber point pl

Parameters:
    point : Pt - The point to test.
    pl : Polyline2D - The closed Polyline2D.

Returns: int The winding number. Zero means outside, non-zero means inside.
Modifiers: inline

Count how many times the polygon winds around the point. If the result is 0 then the point is outside of the Polyline2D. A non-zero value indicates the point is inside.

The first and last point of the Polyline2D need to be identical for correct results. Boundary cases: Points exactly on edges or vertices may return inconsistent results due to floating-point precision. For points on horizontal edges, behavior depends on the edge direction. This method Handles self-intersecting polygons more intuitively than the pl.ContainsPt method.

point : Pt

The point to test.

pl : Polyline2D

The closed Polyline2D.

Returns: int

The winding number. Zero means outside, non-zero means inside.

Polyline2D.xys p

Full Usage: Polyline2D.xys p

Parameters:
Returns: ResizeArray<float>
Modifiers: inline

Gets the X and Y interleaved ResizeArray of the Polyline2D: x0, y0, x1, y1, ... This is the live internal buffer, so changes to the list will be reflected in the Polyline2D.

p : Polyline2D
Returns: ResizeArray<float>

Type something to start searching.