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
|
|
Create a new empty Polyline2D with predefined point count capacity.
|
Instance members
| Instance member |
Description
|
|
Adds a point to the end of the Polyline2D.
|
Full Usage:
this.AddXY
Parameters:
float
y : float
|
Adds a point from x and y coordinates.
|
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.
|
Full Usage:
this.AsFSharpCode
Returns: string
|
Format a 2D polyline into an F# code string that can be used to recreate the polyline.
|
|
Converts the float buffer of the Polyline2D into a list of Points. Use .XYs to access the live internal buffer.
|
Full Usage:
this.AsString
Returns: string
|
Format Polyline2D into string including its length.
|
|
Gets bounding rectangle of the Polyline2D
|
|
Returns the average center of all points of the Polyline2D.
|
|
Creates a copy of the Polyline2D. Same as polyline.Duplicate()
|
Full Usage:
this.Close
Parameters:
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.
|
|
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 .
|
Full Usage:
this.ClosestParameterXY
Parameters:
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 .
|
|
|
|
Returns the index into the Polyline2D's point list of the point that is closest to the given point.
|
Full Usage:
this.ContainsPt
Parameters:
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.
|
Full Usage:
this.ContainsXY
Parameters:
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.
|
|
Returns the distance of the test point to the closest point on the Polyline2D.
|
|
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.
|
Full Usage:
this.DistanceToXY
Parameters:
float
y : float
Returns: float
|
Returns the distance of the test point to the closest point on the Polyline2D.
|
Full Usage:
this.DistanceToXYSigned
Parameters:
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.
|
|
Creates a copy of the Polyline2D Same as polyline.Clone()
|
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.
|
|
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. |
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. |
|
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.
|
|
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).
|
|
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.
|
|
Gets the first segment of the Polyline2D.
|
|
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 )
|
|
|
Full Usage:
this.GetX
Parameters:
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 )
|
Full Usage:
this.GetY
Parameters:
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 )
|
Full Usage:
this.IsAlmostClosed
Parameters:
float
Returns: bool
|
Tests if Polyline2D is closed within given tolerance. Returns FALSE if the Polyline2D has fewer than 3 points.
|
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.
|
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.
|
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.
|
|
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.
|
|
Gets the last segment of the Polyline2D.
|
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.
|
Moves the Polyline2D in place by a vector.
|
|
Full Usage:
this.MovePoint
Parameters:
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 )
|
Full Usage:
this.MovePointPreservingClosure
Parameters:
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 )
|
Full Usage:
this.MoveX
Parameters:
float
|
Moves the Polyline2D in place by a given distance in X direction.
|
Full Usage:
this.MoveXY
Parameters:
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 )
|
Full Usage:
this.MoveXYPreservingClosure
Parameters:
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 )
|
Full Usage:
this.MoveY
Parameters:
float
|
Moves the Polyline2D in place by a given distance in Y direction.
|
Full Usage:
this.PointCount
Returns: int
|
Gets the number of points in the Polyline2D.
|
Full Usage:
this.RemoveDuplicateAndCollinearPoints
Parameters:
float<MeasureProduct<cosine, MeasureOne>>
distanceTolerance : float
|
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.
|
Full Usage:
this.RemoveDuplicatePoints
Parameters:
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.
|
Full Usage:
this.RemoveDuplicatePointsAndReport
Parameters:
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.
|
Full Usage:
this.RemoveDuplicatePointsFaithfully
Parameters:
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.
|
Full Usage:
this.RemoveUTurns
Parameters:
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``'.
|
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.
|
Full Usage:
this.RemoveUTurnsDeeply
Parameters:
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``'.
|
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.
|
Full Usage:
this.Reverse
|
Reverses the order of the Polyline2D in place. |
|
Rotates the Polyline2D in place around the world origin by a Rotation2D.
|
Full Usage:
this.RotateAround
Parameters:
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.
|
Full Usage:
this.RotateDegrees
Parameters:
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).
|
Full Usage:
this.RotateDegreesAround
Parameters:
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.
|
Full Usage:
this.RotateRadians
Parameters:
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).
|
Full Usage:
this.RotateRadiansAround
Parameters:
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.
|
Full Usage:
this.Scale
Parameters:
float
|
Scales the Polyline2D in place by a given factor. Scale center is World Origin 0,0
|
Full Usage:
this.ScaleOn
Parameters:
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.
|
|
Gets or sets the second last point of the Polyline2D. Setting it mutates the Polyline2D in place.
|
|
Gets or sets the second point of the Polyline2D. This is the point at index 1. Setting it mutates the Polyline2D in place.
|
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 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.
|
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 all segments of the Polyline2D as a list of Line2D.
|
|
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 )
|
|
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 )
|
Full Usage:
this.SetXY
Parameters:
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 )
|
Full Usage:
this.SetXYPreservingClosure
Parameters:
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 )
|
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.
|
|
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.
|
Full Usage:
this.WindingNumber
Parameters:
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.
|
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.
|
Static members
| Static member |
Description
|
|
Adds a point to the end of the Polyline2D.
|
|
Adds a point from x and y coordinates.
|
|
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.
|
|
Format a 2D polyline into an F# code string that can be used to recreate the polyline.
|
Full Usage:
Polyline2D.asPoints p
Parameters:
Polyline2D
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.
|
|
|
Full Usage:
Polyline2D.boundingRectangle p
Parameters:
Polyline2D
Returns: BRect
Modifiers: inline |
|
|
|
|
|
Full Usage:
Polyline2D.close toleranceForAddingPoint pl
Parameters:
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.
|
Full Usage:
Polyline2D.closestParameter pt pl
Parameters:
Pt
pl : Polyline2D
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 .
|
Full Usage:
Polyline2D.closestParameterXY x y pl
Parameters:
float
y : float
pl : Polyline2D
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 .
|
Full Usage:
Polyline2D.closestPoint pt pl
Parameters:
Pt
pl : Polyline2D
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.
|
Full Usage:
Polyline2D.closestPointIndex pt pl
Parameters:
Pt
pl : Polyline2D
Returns: int
Modifiers: inline |
Returns the index into the Polyline2D's point list of the point that is closest to the given point.
|
Full Usage:
Polyline2D.containsPt pt pl
Parameters:
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.
|
Full Usage:
Polyline2D.containsXY x y pl
Parameters:
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.
|
Full Usage:
Polyline2D.createEmpty capacity
Parameters:
int
Returns: Polyline2D
Modifiers: inline |
Create a new empty Polyline2D without any points. But predefined capacity.
|
|
Creates a counter-clockwise Polyline2D starting at the MinX and MinY for the bounding rectangle
|
|
Creates a clockwise Polyline2D starting at the MinX and MinY for the bounding rectangle
|
Full Usage:
Polyline2D.createFromMembersXY xyObjs
Parameters:
^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).
|
Full Usage:
Polyline2D.createFromMembersxy xyObjs
Parameters:
^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).
|
|
Create a new Polyline2D by copying over all points. This will allocate a new ResizeArray and copy all points.
|
|
Creates a counter-clockwise closed Polyline2D starting at the Origin of the Rect2D
|
|
Creates a clockwise closed Polyline2D starting at the Origin of the Rect2D
|
|
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.
|
Full Usage:
Polyline2D.distanceToPt pt pl
Parameters:
Pt
pl : Polyline2D
Returns: float
Modifiers: inline |
Returns the distance of the test point to the closest point on the Polyline2D.
|
Full Usage:
Polyline2D.distanceToPtSigned pt pl
Parameters:
Pt
pl : Polyline2D
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.
|
Full Usage:
Polyline2D.distanceToXY x y pl
Parameters:
float
y : float
pl : Polyline2D
Returns: float
Modifiers: inline |
Returns the distance of the test point to the closest point on the Polyline2D.
|
Full Usage:
Polyline2D.distanceToXYSigned x y pl
Parameters:
float
y : float
pl : Polyline2D
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.
|
|
|
|
Gets the last or end point of the Polyline2D. This is the point at index Points.Count - 1. Same as Polyline2D.LastPoint
|
Full Usage:
Polyline2D.ensureClockwise pl
Parameters:
Polyline2D
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.
|
Full Usage:
Polyline2D.ensureCounterClockwise pl
Parameters:
Polyline2D
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.
|
Full Usage:
Polyline2D.equalsExact pl1 pl2
Parameters:
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.
|
Full Usage:
Polyline2D.equalsWithin tol pl1 pl2
Parameters:
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.
|
|
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.
|
Full Usage:
Polyline2D.findAllSelfIntersections pl
Parameters:
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.
|
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.
|
Full Usage:
Polyline2D.findLabelPoint precision pl
Parameters:
float
pl : Polyline2D
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).
|
|
Gets the first point of the Polyline2D. This is the point at index 0. Same as Polyline2D.Start
|
|
|
Full Usage:
Polyline2D.getPoint pointIndex p
Parameters:
int
p : Polyline2D
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 )
|
Full Usage:
Polyline2D.getSegment i p
Parameters:
int
p : Polyline2D
Returns: Line2D
Modifiers: inline |
|
Full Usage:
Polyline2D.getX pointIndex p
Parameters:
int
p : Polyline2D
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 )
|
Full Usage:
Polyline2D.getY pointIndex p
Parameters:
int
p : Polyline2D
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 )
|
Full Usage:
Polyline2D.isAlmostClosed tolerance p
Parameters:
float
p : Polyline2D
Returns: bool
Modifiers: inline |
Tests if Polyline2D is closed within given tolerance. Returns FALSE if the Polyline2D has fewer than 3 points.
|
|
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.
|
|
Tests if Polyline2D start and end points are exactly the same. Returns FALSE if the Polyline2D has fewer than 3 points.
|
Full Usage:
Polyline2D.isCounterClockwise p
Parameters:
Polyline2D
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.
|
Full Usage:
Polyline2D.iter action pl
Parameters:
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.
|
Full Usage:
Polyline2D.iterLineSegments action pl
Parameters:
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.
|
Full Usage:
Polyline2D.iterPt action pl
Parameters:
Pt -> unit
-
A function that takes a point.
pl : Polyline2D
-
The Polyline2D to iterate over.
|
Iterate over each point in the Polyline2D.
|
Full Usage:
Polyline2D.iterSegments action pl
Parameters:
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.
|
Full Usage:
Polyline2D.iteri action pl
Parameters:
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.
|
Full Usage:
Polyline2D.iteriPt action pl
Parameters:
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.
|
|
Gets the last point of the Polyline2D. This is the point at index Points.Count - 1. Same as Polyline2D.End
|
|
|
|
Gets the length of the Polyline2D. The sum of the lengths of all segments. Returns 0.0 if there are fewer than 2 points.
|
Full Usage:
Polyline2D.map mapping pl
Parameters:
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.
|
Full Usage:
Polyline2D.mapPt mapping pl
Parameters:
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.
|
Full Usage:
Polyline2D.mapi mapping pl
Parameters:
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.
|
Full Usage:
Polyline2D.mapiPt mapping pl
Parameters:
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.
|
|
Returns a new Polyline2D moved by a vector. The input Polyline2D is not changed.
|
Full Usage:
Polyline2D.movePoint pointIndex v p
Parameters:
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.
|
Full Usage:
Polyline2D.movePointPreservingClosure pointIndex v p
Parameters:
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.
|
Full Usage:
Polyline2D.moveX distance pl
Parameters:
float
pl : Polyline2D
Returns: Polyline2D
|
Returns a new Polyline2D moved by a given distance in X direction. The input Polyline2D is not changed.
|
Full Usage:
Polyline2D.moveXY pointIndex x y p
Parameters:
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.
|
Full Usage:
Polyline2D.moveXYPreservingClosure pointIndex x y p
Parameters:
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.
|
Full Usage:
Polyline2D.moveY distance pl
Parameters:
float
pl : Polyline2D
Returns: Polyline2D
|
Returns a new Polyline2D moved by a given distance in Y direction. The input Polyline2D is not changed.
|
Full Usage:
Polyline2D.offset offsetDistance pl
Parameters:
float
pl : Polyline2D
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.
|
Full Usage:
Polyline2D.offsetCustom (polyLine, constantOffsetDistance, ?loop, ?checkOrientation, ?uTurnBehavior, ?useUTurnBehaviorAbove)
Parameters:
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.
|
Full Usage:
Polyline2D.offsetVariable multipleOffsetDistances pl
Parameters:
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.
|
Full Usage:
Polyline2D.offsetVariableCustom (polyLine, multipleOffsetDistances, ?loop, ?checkOrientation, ?varDistParallelBehavior, ?uTurnBehavior, ?useVarDistParallelBehaviorBelow, ?useUTurnBehaviorAbove)
Parameters:
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.
|
|
|
Full Usage:
Polyline2D.removeDuplicateAndCollinearPoints angleTolerance distanceTolerance pl
Parameters:
float<MeasureProduct<cosine, MeasureOne>>
distanceTolerance : float
pl : Polyline2D
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.
|
Full Usage:
Polyline2D.removeDuplicatePoints distanceTolerance pl
Parameters:
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.
|
Full Usage:
Polyline2D.removeDuplicatePointsAndReport distanceTolerance pl
Parameters:
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.
|
Full Usage:
Polyline2D.removeDuplicatePointsFaithfully distanceTolerance pl
Parameters:
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.
|
Full Usage:
Polyline2D.removeUTurns minCos polyLine
Parameters:
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'.
|
Full Usage:
Polyline2D.removeUTurnsDeeply minCos polyLine
Parameters:
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.
|
|
Returns a new Polyline2D with the order of the points reversed. The input Polyline2D is not changed. Use p.Reverse() to reverse in place.
|
|
Returns a new Polyline2D rotated around the world origin by a Rotation2D. The input Polyline2D is not changed.
|
Full Usage:
Polyline2D.rotateAround cen r pl
Parameters:
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.
|
Full Usage:
Polyline2D.rotateDegrees angDegree pl
Parameters:
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.
|
Full Usage:
Polyline2D.rotateDegreesAround cen angDegree pl
Parameters:
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.
|
Full Usage:
Polyline2D.rotateRadians angRadians pl
Parameters:
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.
|
Full Usage:
Polyline2D.rotateRadiansAround cen angRadians pl
Parameters:
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.
|
Full Usage:
Polyline2D.scale factor pl
Parameters:
float
pl : Polyline2D
Returns: Polyline2D
|
Returns a new Polyline2D scaled by a given factor. The input Polyline2D is not changed. Scale center is World Origin 0,0
|
Full Usage:
Polyline2D.scaleOn cen factor pl
Parameters:
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.
|
|
|
|
|
|
Gets the number of segments in the Polyline2D. This is the point count minus one, but never negative.
|
Full Usage:
Polyline2D.segmentVectors p
Parameters:
Polyline2D
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.
|
Full Usage:
Polyline2D.segmentVectorsXY p
Parameters:
Polyline2D
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.
|
Full Usage:
Polyline2D.segments p
Parameters:
Polyline2D
Returns: ResizeArray<Line2D>
Modifiers: inline |
Returns all segments of the Polyline2D as a list of Line2D.
|
Full Usage:
Polyline2D.setPoint pointIndex pt p
Parameters:
int
pt : Pt
p : Polyline2D
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 )
|
Full Usage:
Polyline2D.setPointPreservingClosure pointIndex pt p
Parameters:
int
pt : Pt
p : Polyline2D
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 )
|
Full Usage:
Polyline2D.setXY pointIndex x y p
Parameters:
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 )
|
Full Usage:
Polyline2D.setXYPreservingClosure pointIndex x y p
Parameters:
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 )
|
|
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.
|
|
Gets the first point of the Polyline2D. This is the point at index 0. Same as Polyline2D.FirstPoint
|
Full Usage:
Polyline2D.subPolyline a b pl
Parameters:
float
b : float
pl : Polyline2D
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).
|
Full Usage:
Polyline2D.tryFind condition pl
Parameters:
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.
|
Full Usage:
Polyline2D.tryFindIndex condition pl
Parameters:
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.
|
Full Usage:
Polyline2D.tryFindLast condition pl
Parameters:
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.
|
Full Usage:
Polyline2D.tryFindLastIndex condition pl
Parameters:
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.
|
Full Usage:
Polyline2D.tryFindSelfIntersection pl
Parameters:
Polyline2D
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.
|
Full Usage:
Polyline2D.windingNumber point pl
Parameters:
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.
|
Full Usage:
Polyline2D.xys p
Parameters:
Polyline2D
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.
|
Euclid