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, ...
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.CloseInPlace
Parameters:
float
-
Optional. 1e-6 by default
The tolerance used to decide whether to snap the last point to the first point.
|
Close the Polyline2D 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.
|
|
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 Polylines point list of the point that is closest to the given point.
|
Full Usage:
this.Contains
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.
|
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 less 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.
|
Full Usage:
this.DistanceToXY
Parameters:
float
y : float
Returns: float
|
Returns the distance of the test point to the closest point on the Polyline2D.
|
|
Creates a copy of the Polyline2D Same as polyline.Clone()
|
Gets or sets last or end point of the Polyline2D This is the point at index Points.Count - 1. Same as Polyline2D.LastPoint
|
|
|
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
|
|
Gets the first segment of the Polyline2D.
|
|
Gets the point at the given position. (does Pt(xys.[position * 2], xys.[position * 2 + 1]) internally)
|
|
|
Full Usage:
this.GetX
Parameters:
int
Returns: float
|
Gets the x coordinate of the point at the given position. (does xys.[position * 2] internally)
|
Full Usage:
this.GetY
Parameters:
int
Returns: float
|
Gets the y coordinate of the point at the given position. (does xys.[position * 2 + 1] internally)
|
Full Usage:
this.IsAlmostClosed
Parameters:
float
Returns: bool
|
Tests if Polyline2D is closed within given tolerance. Returns False if the Polyline2D has less 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 less than 3 points.
|
Full Usage:
this.IsCounterClockwise
Returns: bool
|
Test if Polyline2D is CounterClockwise. 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
|
|
Gets the last segment of the Polyline2D.
|
Full Usage:
this.Length
Returns: float
|
Gets the length of the Polyline2D Returns 0.0 if there are less than 2 points.
|
|
|
|
|
|
|
Full Usage:
this.PointCount
Returns: int
|
Gets the count of points in the Polyline2D
|
|
Returns new Polyline2D in reversed Order.
|
Full Usage:
this.ReverseInPlace
|
Reverse order of the Polyline2D in place. |
|
|
|
Rotation a Polyline2D around a given center point by a Rotation2D.
|
|
Scales the 2D polyline by a given factor. Scale center is World Origin 0,0
|
|
Scales the 2D polyline by a given factor on a given center point.
|
|
Gets or sets the second last point of the Polyline2D.
|
|
Gets or sets the second point of the Polyline2D. This is the point at index 1.
|
Full Usage:
this.SegmentCount
Returns: int
|
Gets the count of segments in the Polyline2D This is poly.Points.Count - 1
|
|
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.
|
Full Usage:
this.SetPointXY
Parameters:
int
x : float
y : float
|
Sets the x and y coordinates of the point at the given index. NOTE: setting the first or last point on a closed Polyline2D might open it. (sets xys.[position * 2] and xys.[position * 2 + 1] internally )
|
Full Usage:
this.SetPointXYClosed
Parameters:
int
x : float
y : float
|
Sets the x and y coordinates of the point at the given position. On a closed Polyline2D, setting the first or last point will set both to the same point. Raises an error if the position is out of range. (sets xys.[position * 2] and xys.[position * 2 + 1] internally)
|
|
Sets the point at given position to the given point. ( sets xys.[position * 2] and xys.[position * 2 + 1] internally)
|
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.
|
|
Calculates the shortest distance from the test point to the polyline with `DistanceTo`, then signs that value by testing containment via the ray-casting based `Contains` 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.SignedDistanceToXY
Parameters:
float
y : float
Returns: float
|
Calculates the shortest distance from the test point to the polyline with `DistanceTo`, then signs that value by testing containment via the ray-casting based `Contains` 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 or sets first point of the Polyline2D This is the point at index 0. Same as Polyline2D.FirstPoint
|
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.Contains 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
pl : Polyline2D
Returns: Polyline2D
|
Returns a new closed Polyline2D. If the first and last point are within the tolerance of each other, the last point is set equal to the first point. Otherwise one point is added. Raises an error if the Polyline2D has fewer than 3 points, same as CloseInPlace.
|
Full Usage:
Polyline2D.closeInPlace 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 reference to the same Polyline2D as the input
|
Close the Polyline2D in place using the given tolerance. 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.
|
Full Usage:
Polyline2D.closestParameter pl pt
Parameters:
Polyline2D
pt : Pt
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 pl x y
Parameters:
Polyline2D
x : float
y : float
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 pl pt
Parameters:
Polyline2D
pt : Pt
Returns: Pt
Modifiers: inline |
Returns the point on the Polyline2D that is the closest point to the given point.
|
Full Usage:
Polyline2D.closestPointIndex pl pt
Parameters:
Polyline2D
pt : Pt
Returns: int
Modifiers: inline |
Returns the index into the Polylines point list of the point that is closest to the given point.
|
Full Usage:
Polyline2D.contains 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 less 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.
|
|
Create a new Polyline2D by using the provided X and Y interleaved ResizeArray directly. Unsafe because later changes to the ResizeArray will be reflected in the Polyline2D.
|
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
|
|
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
|
Full Usage:
Polyline2D.createFromXYMembers 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.createFromxyMembers 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).
|
Full Usage:
Polyline2D.distanceTo pl pt
Parameters:
Polyline2D
pt : Pt
Returns: float
Modifiers: inline |
Returns the distance of the test point to the closest point on the Polyline2D.
|
Full Usage:
Polyline2D.distanceToXY pl x y
Parameters:
Polyline2D
x : float
y : float
Returns: float
Modifiers: inline |
Returns the distance of the test point to the closest point on the Polyline2D.
|
|
|
|
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 |
Tests if Polyline2D is Clockwise. Returns the same instance if the Polyline2D is already Clockwise, otherwise returns a new reversed Polyline2D.
|
Full Usage:
Polyline2D.ensureClockwiseInPlace pl
Parameters:
Polyline2D
Returns: Polyline2D
Modifiers: inline |
Tests if Polyline2D is Clockwise. If not reverse the Polyline2D in place. Always returns the same instance.
|
Full Usage:
Polyline2D.ensureCounterClockwise pl
Parameters:
Polyline2D
Returns: Polyline2D
Modifiers: inline |
Tests if Polyline2D is Counter Clockwise. Returns the same instance if the Polyline2D is already Counter Clockwise, otherwise returns a new reversed Polyline2D.
|
Full Usage:
Polyline2D.ensureCounterClockwiseInPlace pl
Parameters:
Polyline2D
Returns: Polyline2D
Modifiers: inline |
Tests if Polyline2D is Counter Clockwise. If not reverse the Polyline2D in place. Always returns the same instance.
|
Full Usage:
Polyline2D.equals 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.
|
Full Usage:
Polyline2D.equalsTol tol pl1 pl2
Parameters:
float
-
The tolerance value for comparing the coordinates.
pl1 : Polyline2D
-
The first Polyline2D instance.
pl2 : Polyline2D
-
The second Polyline2D instance.
Returns: bool
|
Tests if two Polyline2D have the same point count and if their corresponding points are equal within a given tolerance.
|
|
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 .
|
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.getPt position p
Parameters:
int
p : Polyline2D
Returns: Pt
Modifiers: inline |
Gets the point at the given position. (does Pt(xys.[position * 2], xys.[position * 2 + 1]) internally)
|
Full Usage:
Polyline2D.getSegment i p
Parameters:
int
p : Polyline2D
Returns: Line2D
Modifiers: inline |
|
Full Usage:
Polyline2D.getX position p
Parameters:
int
p : Polyline2D
Returns: float
Modifiers: inline |
Gets the x coordinate of the point at the given index. (does xys.[position * 2] internally)
|
Full Usage:
Polyline2D.getXYs 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.
|
Full Usage:
Polyline2D.getY position p
Parameters:
int
p : Polyline2D
Returns: float
Modifiers: inline |
Gets the y coordinate of the point at the given index. (does xys.[position * 2 + 1] internally)
|
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 less 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 less than 3 points.
|
Full Usage:
Polyline2D.isCounterClockwise p
Parameters:
Polyline2D
Returns: bool
Modifiers: inline |
Test if Polyline2D is CounterClockwise. 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 and perform an action.
|
Full Usage:
Polyline2D.iterPtSkipLast action pl
Parameters:
Pt -> unit
-
A function that takes a point.
pl : Polyline2D
-
The Polyline2D to iterate over.
Modifiers: inline |
Iterate over each point in the Polyline2D except the last point.
|
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.iterSkipLast 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 except the last point.
|
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 the position of the point (index/2) and the point itself.
pl : Polyline2D
-
The Polyline2D to iterate over.
|
Iterate over each point in the Polyline2D with index and perform an action.
|
|
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.
|
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 the position of the point (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 point position (not float index). Returns new Polyline2D.
|
|
Move a Polyline2D by a vector. (same as Polyline2D.translate)
|
Full Usage:
Polyline2D.moveX distance pl
Parameters:
float
pl : Polyline2D
Returns: Polyline2D
|
Returns a Polyline2D moved by a given distance in X direction.
|
Full Usage:
Polyline2D.moveY distance pl
Parameters:
float
pl : Polyline2D
Returns: Polyline2D
|
Returns a Polyline2D moved by a given distance in Y direction.
|
Full Usage:
Polyline2D.offset (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.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.
|
Full Usage:
Polyline2D.offsetVar (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 colinear 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.``5.0`` `.
The angle between normals below which points are considered colinear and VarDistParallelBehavior is applied if distances are not the same.
?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 colinear segments. But this can be configured with optional parameters.
|
|
|
Full Usage:
Polyline2D.removeDuplicateAndColinearPoints angleTolerance distanceTolerance pl
Parameters:
float<MeasureProduct<cosine, MeasureOne>>
distanceTolerance : float
pl : Polyline2D
Returns: Polyline2D
|
Removes consecutive duplicate points and colinear points from the Polyline2D within given tolerances. This algorithm allows the last and first point to be identical if the Polyline2D is closed. Colinear 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 colinear segments, the first point is replaced with the last non-colinear point. So the joint of the loop is now moved to the last non-colinear point. So that there are no colinear 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
|
Removes consecutive duplicate points from the Polyline2D within a given tolerance. 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.removeDuplicatePointsFaithfully distanceTolerance pl
Parameters:
float
-
The distance within which points are considered duplicates.
pl : Polyline2D
-
A 2D Polyline, open or closed.
Returns: Polyline2D
|
Removes consecutive duplicate points from the Polyline2D within a given tolerance. This algorithm ensures to keep edges in their position by re-intersects 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
If no U-turns are present, the List of points of the original Polyline2D is reused and a new Polyline2D is created with that list.
If U-turns are present, a new ResizeArray of points is returned with simple U-turns removed.
|
Removes simple sharp U-Turns from a Polyline The Offset2D module also has a removeUTurns function that takes precomputed unit vectors and is therefore more efficient. For nested U-turns and colinear points in U-turns segments use 'removeUTurnsDeeply'. That function calls repeatedly until no more U-turns are present.
|
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
If no U-turns are present, the List of points of the original Polyline2D is reused and a new Polyline2D is created with that list.
If U-turns are present, a new ResizeArray of points is returned with all U-turns removed.
|
Removes all sharp U-Turns from a Polyline 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 colinear points in U-turns segments.
|
|
|
Full Usage:
Polyline2D.reverseInPlace p
Parameters:
Polyline2D
-
The Polyline2D to reverse.
Returns: Polyline2D
A reference to the same Polyline2D as the input
|
Reverse order of the Polyline2D in place.
|
|
|
Full Usage:
Polyline2D.rotateWithCenter cen r pl
Parameters:
Pt
r : Rotation2D
pl : Polyline2D
Returns: Polyline2D
|
Rotation a Polyline2D round given center point an a local Z-axis.
|
Full Usage:
Polyline2D.scale factor pl
Parameters:
float
pl : Polyline2D
Returns: Polyline2D
|
Scales the Polyline2D by a given factor. Scale center is World Origin 0,0 Returns a new Polyline2D.
|
Full Usage:
Polyline2D.scaleOn cen factor pl
Parameters:
Pt
factor : float
pl : Polyline2D
Returns: Polyline2D
Modifiers: inline |
Scales the 2D polyline by a given factor on a given center point.
|
|
|
|
|
|
|
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.
|
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.setPointXY x y position p
Parameters:
float
y : float
position : int
p : Polyline2D
Modifiers: inline |
Sets the x and y coordinates of the point at the given index. NOTE: setting the first or last point on a closed Polyline2D might open it. (sets xys.[position * 2] and xys.[position * 2 + 1] internally )
|
Full Usage:
Polyline2D.setPointXYClosed x y position p
Parameters:
float
y : float
position : int
p : Polyline2D
Modifiers: inline |
Sets the x and y coordinates of the point at the given index. On a closed Polyline2D, setting the first or last point will set both to the same point. Raises an error if the index is out of range. (sets xys.[position * 2] and xys.[position * 2 + 1] internally)
|
Full Usage:
Polyline2D.setPt position pt p
Parameters:
int
pt : Pt
p : Polyline2D
Modifiers: inline |
Sets the point at given position to the given point. ( sets xys.[position * 2] and xys.[position * 2 + 1] internally)
|
|
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.
|
Full Usage:
Polyline2D.signedDistanceTo point pl
Parameters:
Pt
pl : Polyline2D
Returns: float
Modifiers: inline |
Calculates the shortest distance from the test point to the polyline with `DistanceTo`, then signs that value by testing containment via the ray-casting based `Contains` 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.signedDistanceToXY 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 `DistanceTo`, then signs that value by testing containment via the ray-casting based `Contains` 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.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 option
Some(Pt) if a point satisfying the condition is found, otherwise None.
Modifiers: inline |
Find the first point in the Polyline2D that satisfies a given condition. Returns Some(point) if found, otherwise None.
|
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 option
Some(index of x) the index of the x value in the polylines flat array if found, otherwise None.
Modifiers: inline |
Find the index of the first point in the Polyline2D that satisfies a given condition. Returns Some(index) if found, otherwise None.
|
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 option
Some(Pt) if a point satisfying the condition is found, otherwise None.
Modifiers: inline |
Find the last point in the Polyline2D that satisfies a given condition. Returns Some(point) if found, otherwise None.
|
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 option
Some(index of x) the index of the x value in the polylines flat array if found, otherwise None.
Modifiers: inline |
Find the index of the last point in the Polyline2D that satisfies a given condition. Returns Some(index) if found, otherwise None.
|
Full Usage:
Polyline2D.tryFindSelfIntersection pl
Parameters:
Polyline2D
Returns: Option<Pt * int * int>
|
Tries to find a self intersection in Polyline2D. This function is optimized for polylines with fewer than 50 points. A closed Polyline2D, is not reported as a self intersection. Also returns Some 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 None. Returns None 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 50 points, tryFindSelfIntersectionWithBRect is faster on .NET, but never on Fable JS.
|
Full Usage:
Polyline2D.tryFindSelfIntersectionWithBRect pl
Parameters:
Polyline2D
Returns: Option<Pt * int * int>
|
Tries to find a self intersection in Polyline2D. This function is the same as tryFindSelfIntersection but with an initial broad phase using bounding rectangles to quickly exclude non-intersecting segments. It runs faster than tryFindSelfIntersection for polylines with more than 50 points, but only on .NET, not on Fable JS. A closed Polyline2D, is not reported as a self intersection. Also returns Some 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 None. Returns None for Polylines with fewer than 3 points (less than two segments). This is an iterative O(n^2) algorithm This function is optimized for polylines with more than 50 points.
|
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.Contains method.
|
Euclid