Header menu logo Euclid

Polyline2D Type

A class holding a list of 2D points representing a mutable 2D Polyline. If the last point is the same as the first point, the Polyline2D is considered closed. The Default constructor uses the provided ResizeArray of points directly, so changes to the list will be reflected in the Polyline2D.

Constructors

Constructor Description

Polyline2D(capacity)

Full Usage: Polyline2D(capacity)

Parameters:
    capacity : int

Returns: Polyline2D

Create a new empty Polyline2D with predefined capacity for the internal list of points.

capacity : int
Returns: Polyline2D

Polyline2D()

Full Usage: Polyline2D()

Returns: Polyline2D

Create a new empty Polyline2D

Returns: Polyline2D

Polyline2D(points)

Full Usage: Polyline2D(points)

Parameters:
    points : ResizeArray<Pt>

Returns: Polyline2D
points : ResizeArray<Pt>
Returns: Polyline2D

Instance members

Instance member Description

this.Area

Full Usage: this.Area

Returns: float

The area of the Polyline2D. Fails if Polyline is not exactly closed. For self intersecting Polylines the result is invalid.

Returns: float

this.AsFSharpCode

Full Usage: this.AsFSharpCode

Returns: string

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

Returns: string

this.AsString

Full Usage: this.AsString

Returns: string

Format Polyline2D into string including its length.

Returns: string

this.BoundingRectangle

Full Usage: this.BoundingRectangle

Returns: BRect

Gets bounding rectangle of the Polyline2D

Returns: BRect

this.Center

Full Usage: this.Center

Returns: Pt

Returns the average center of all points of the Polyline2D.

Returns: Pt

this.Clone

Full Usage: this.Clone

Returns: Polyline2D

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

Returns: Polyline2D

this.CloseInPlace

Full Usage: this.CloseInPlace

Parameters:
    toleranceForAddingPoint : float

Close the Polyline2D if it is not already closed. If the ends are closer than the tolerance. The last point is set to equal the first point. Else the start point is added to the end of the Polyline2D.

toleranceForAddingPoint : float

this.ClosestParameter

Full Usage: this.ClosestParameter

Parameters:
Returns: float

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

p : Pt
Returns: float

this.ClosestPoint

Full Usage: this.ClosestPoint

Parameters:
Returns: Pt

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

p : Pt
Returns: Pt

this.ClosestVertex

Full Usage: this.ClosestVertex

Parameters:
Returns: int

Returns the index into the Polylines point list of the vertex that is closest to the given point.

p : Pt
Returns: int

this.Contains

Full Usage: this.Contains

Parameters:
    pt : Pt - The point to test.

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

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

The first and last point of the Polyline2D need to be identical for correct results. Self-intersecting polygons give "alternating" inside/outside regions Uses ray casting: runs an infinite horizontal ray (increasing x, fixed y) from the test point and counts edge crossings. Each crossing toggles inside/outside state (Jordan curve theorem). Always returns FALSE if the Polyline2D has 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.

pt : Pt

The point to test.

Returns: bool

TRUE if the point is inside, FALSE otherwise.

this.DistanceTo

Full Usage: this.DistanceTo

Parameters:
Returns: float

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

p : Pt
Returns: float

this.Duplicate

Full Usage: this.Duplicate

Returns: Polyline2D

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

Returns: Polyline2D

this.End

Full Usage: this.End

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

this.EvaluateAt

Full Usage: this.EvaluateAt

Parameters:
    t : float

Returns: Pt

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

t : float
Returns: Pt

this.FindLablePoint

Full Usage: this.FindLablePoint

Parameters:
    precision : float

Returns: Pt * float

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

precision : float
Returns: Pt * float

this.FirstPoint

Full Usage: this.FirstPoint

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

this.FirstSegment

Full Usage: this.FirstSegment

Returns: Line2D

Gets the first segment of the Polyline2D.

Returns: Line2D

this.GetSegment

Full Usage: this.GetSegment

Parameters:
    i : int

Returns: Line2D

Gets the segment at index i of the Polyline2D.

i : int
Returns: Line2D

this.IsAlmostClosed

Full Usage: this.IsAlmostClosed

Parameters:
    tolerance : float

Returns: bool

Tests if Polyline2D is closed within given tolerance. Returns False if the Polyline2D has less than 3 points.

tolerance : float
Returns: bool

this.IsClockwise

Full Usage: this.IsClockwise

Returns: bool

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

Returns: bool

this.IsClosed

Full Usage: this.IsClosed

Returns: bool

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

Returns: bool

this.IsCounterClockwise

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.

Returns: bool

this.LastPoint

Full Usage: this.LastPoint

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

this.LastPointIndex

Full Usage: this.LastPointIndex

Returns: int

Gets the index of the last point in the Polyline2D. points.Count - 1

Returns: int

this.LastSegment

Full Usage: this.LastSegment

Returns: Line2D

Gets the segment at index i of the Polyline2D.

Returns: Line2D

this.LastSegmentIndex

Full Usage: this.LastSegmentIndex

Returns: int

Gets the index of the last segment in the Polyline2D. This is poly.Points.Count - 2

Returns: int

this.Length

Full Usage: this.Length

Returns: float

Gets the length of the Polyline2D Returns 0.0 if there are less than 2 points.

Returns: float

this.PointCount

Full Usage: this.PointCount

Returns: int

Gets the count of points in the Polyline2D

Returns: int

this.Points

Full Usage: this.Points

Returns: ResizeArray<Pt>

Gets the internal list of all Points of the Polyline2D. This is not a copy, so changes to the list will be reflected in the Polyline2D.

Returns: ResizeArray<Pt>

this.Reverse

Full Usage: this.Reverse

Returns: Polyline2D

Returns new Polyline2D in reversed Order.

Returns: Polyline2D

this.ReverseInPlace

Full Usage: this.ReverseInPlace

Reverse order of the Polyline2D in place.

this.Scale

Full Usage: this.Scale

Parameters:
    factor : float

Returns: Polyline2D

Scales the 2D polyline by a given factor. Scale center is World Origin 0,0

factor : float
Returns: Polyline2D

this.ScaleOn

Full Usage: this.ScaleOn

Parameters:
    cen : Pt
    factor : float

Returns: Polyline2D

Scales the 2D polyline by a given factor on a given center point.

cen : Pt
factor : float
Returns: Polyline2D

this.SecondLastPoint

Full Usage: this.SecondLastPoint

Gets or sets the second last point of the Polyline2D.

this.SecondPoint

Full Usage: this.SecondPoint

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

this.SegmentCount

Full Usage: this.SegmentCount

Returns: int

Gets the count of segments in the Polyline2D This is poly.Points.Count - 1

Returns: int

this.SegmentVectors

Full Usage: this.SegmentVectors

Returns: ResizeArray<Vc>

Returns the line vectors of all segments of the Polyline2D as a list of Vc.

Returns: ResizeArray<Vc>

this.Segments

Full Usage: this.Segments

Returns: ResizeArray<Line2D>

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

Returns: ResizeArray<Line2D>

this.SetVertex

Full Usage: this.SetVertex

Parameters:
    idx : int
    pt : Pt

Sets the vertex at given index to the given point. On a closed Polyline2D, setting the first or last point will set both to the same point.

idx : int
pt : Pt

this.SignedArea

Full Usage: this.SignedArea

Returns: float

The signed area of the Polyline2D . If it is positive the Polyline2D is Counter Clockwise. Polyline does not need to be exactly closed. But then result might be wrong. Or without meaning. For self intersecting Polylines the result is also invalid.

Returns: float

this.SignedDistanceTo

Full Usage: this.SignedDistanceTo

Parameters:
    point : Pt

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.

point : Pt
Returns: float

this.Start

Full Usage: this.Start

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

this.WindingNumber

Full Usage: this.WindingNumber

Parameters:
    point : Pt - The point to test.

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

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

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

point : Pt

The point to test.

Returns: int

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

Static members

Static member Description

Polyline2D.close pl

Full Usage: Polyline2D.close pl

Parameters:
Returns: Polyline2D

Returns a new closed Polyline2D. If the first and last point are within 1e-6 of each other, the last point is set equal to the first point. Otherwise one point is added.

pl : Polyline2D
Returns: Polyline2D

Polyline2D.closeInPlace pl

Full Usage: Polyline2D.closeInPlace pl

Parameters:

Closes the Polyline2D in place by adding a point. If the first and last point are within 1e-6 of each other, the last point is set equal to the first point instead.

pl : Polyline2D

Polyline2D.closestParameter pl pt

Full Usage: Polyline2D.closestParameter pl pt

Parameters:
Returns: float
Modifiers: inline

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

pl : Polyline2D
pt : Pt
Returns: float

Polyline2D.closestPoint pl pt

Full Usage: Polyline2D.closestPoint pl pt

Parameters:
Returns: Pt
Modifiers: inline

Returns the point on the Polyline2D that is the closest point to the given point.

pl : Polyline2D
pt : Pt
Returns: Pt

Polyline2D.closestVertex pl pt

Full Usage: Polyline2D.closestVertex pl pt

Parameters:
Returns: int
Modifiers: inline

Returns the index into the Polylines point list of the vertex that is closest to the given point.

pl : Polyline2D
pt : Pt
Returns: int

Polyline2D.contains pt pl

Full Usage: Polyline2D.contains pt pl

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

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

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

The first and last point of the Polyline2D need to be identical for correct results. Self-intersecting polygons give "alternating" inside/outside regions Uses ray casting: runs an infinite horizontal ray (increasing x, fixed y) from the test point and counts edge crossings. Each crossing toggles inside/outside state (Jordan curve theorem). Always returns FALSE if the Polyline2D has 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.

pt : Pt

The point to test.

pl : Polyline2D

The closed Polyline2D.

Returns: bool

TRUE if the point is inside, FALSE otherwise.

Polyline2D.create points

Full Usage: Polyline2D.create points

Parameters:
    points : Pt seq

Returns: Polyline2D
Modifiers: inline

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

points : Pt seq
Returns: Polyline2D

Polyline2D.createDirectlyUnsafe points

Full Usage: Polyline2D.createDirectlyUnsafe points

Parameters:
    points : ResizeArray<Pt>

Returns: Polyline2D

Create a new Polyline2D by using the provided ResizeArray directly. Unsafe because all later changes to the ResizeArray will be reflected in the Polyline2D.

points : ResizeArray<Pt>
Returns: Polyline2D

Polyline2D.createEmpty capacity

Full Usage: Polyline2D.createEmpty capacity

Parameters:
    capacity : int

Returns: Polyline2D
Modifiers: inline

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

capacity : int
Returns: Polyline2D

Polyline2D.distanceTo pl pt

Full Usage: Polyline2D.distanceTo pl pt

Parameters:
Returns: float
Modifiers: inline

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

pl : Polyline2D
pt : Pt
Returns: float

Polyline2D.ende p

Full Usage: Polyline2D.ende p

Parameters:
Returns: Pt

Gets last or end point of the Polyline2D

p : Polyline2D
Returns: Pt

Polyline2D.equals tol a b

Full Usage: Polyline2D.equals tol a b

Parameters:
Returns: bool

Tests if two Polyline2D have the same number of points and points are equal within a given tolerance.

tol : float
a : Polyline2D
b : Polyline2D
Returns: bool

Polyline2D.evaluateAt t pl

Full Usage: Polyline2D.evaluateAt t pl

Parameters:
Returns: Pt

Returns the point at a given parameter on the Polyline2D. The integer part of the parameter is the index of the segment that the point is on. The fractional part of the parameter is the parameter form 0.0 to 1.0 on the segment. The domain Polyline2D starts at 0.0 and ends at point count.

t : float
pl : Polyline2D
Returns: Pt

Polyline2D.findLablePoint precision pl

Full Usage: Polyline2D.findLablePoint precision pl

Parameters:
Returns: Pt * float

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

precision : float
pl : Polyline2D
Returns: Pt * float

Polyline2D.length p

Full Usage: Polyline2D.length p

Parameters:
Returns: float
Modifiers: inline

Gets the length of the Polyline2D. The sum of the lengths of all segments.

p : Polyline2D
Returns: float

Polyline2D.map mapping pl

Full Usage: Polyline2D.map mapping pl

Parameters:
Returns: Polyline2D

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

mapping : Pt -> Pt
pl : Polyline2D
Returns: Polyline2D

Polyline2D.move v pl

Full Usage: Polyline2D.move v pl

Parameters:
Returns: Polyline2D

Move a Polyline2D by a vector. (same as Polyline2D.translate)

v : Vc
pl : Polyline2D
Returns: Polyline2D

Polyline2D.moveX distance pl

Full Usage: Polyline2D.moveX distance pl

Parameters:
Returns: Polyline2D

Returns a Polyline2D moved by a given distance in X direction.

distance : float
pl : Polyline2D
Returns: Polyline2D

Polyline2D.moveY distance pl

Full Usage: Polyline2D.moveY distance pl

Parameters:
Returns: Polyline2D

Returns a Polyline2D moved by a given distance in Y direction.

distance : float
pl : Polyline2D
Returns: Polyline2D

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

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

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

Returns: Polyline2D A new 2D polyline.

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

polyLine : Polyline2D

A 2D Polyline, open or closed.

constantOffsetDistance : float

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

?loop : bool

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

?checkOrientation : bool

bool, Optional(true). By default the algorithm always checks if the polyline is clockwise or counter clockwise. So that positive offset distances are always towards the inside of the polyline. Set this parameter to false if you are sure that the input polyline is counter clockwise or if you want to skip this check.

?uTurnBehavior : UTurn

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

?useUTurnBehaviorAbove : MeasureProduct<cosine, MeasureOne>

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

Returns: Polyline2D

A new 2D polyline.

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

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

Parameters:
    polyLine : Polyline2D - A 2D Polyline, open or closed.
    multipleOffsetDistances : 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 are sure that the input polyline is counter clockwise or if you want to skip this check.
    ?varDistParallelBehavior : VarDistParallel - Optional. Default value: `Offset2D.VarDistParallelBehavior.Fail`. What to do with colinear segments below 'useVarDistParallelBehaviorBelow' degrees when offset distances are different too.
    ?uTurnBehavior : UTurn - Optional. Default value: `Offset2D.UTurnBehavior.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.

polyLine : Polyline2D

A 2D Polyline, open or closed.

multipleOffsetDistances : 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 are sure that the input polyline is counter clockwise or if you want to skip this check.

?varDistParallelBehavior : VarDistParallel

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

?uTurnBehavior : UTurn

Optional. Default value: `Offset2D.UTurnBehavior.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.

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

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

Parameters:
    polyLine : Polyline2D - A 2D Polyline, open or closed.
    multipleOffsetDistances : IList<float> - The parallel offset distances for each segment of the polyline. A positive distance offsets inwards in corners, a negative offset outwards. For open and closed polylines this list of distances must have one item less than number of points in the polyline. Except if the polyline is open and the loop parameter is set to true. Then points and distances list shall have the same count.
    ?loop : bool - bool, Optional (false). Set to true to explicitly consider last point and first point to be from a closed loop, even if they are not at the same location.
    ?checkOrientation : bool - bool, Optional(true). By default the algorithm always checks if the polyline is clockwise or counter clockwise. So that positive offset distances are always towards the inside of the polyline. Set this parameter to false if you are sure that the input polyline is counter clockwise or if you want to skip this check.
    ?varDistParallelBehavior : VarDistParallel - Optional. Default value: `Offset2D.VarDistParallelBehavior.Fail`. What to do with colinear segments below 'useVarDistParallelBehaviorBelow' degrees when offset distances are different too.
    ?uTurnBehavior : UTurn - Optional. Default value: `Offset2D.UTurnBehavior.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.

polyLine : Polyline2D

A 2D Polyline, open or closed.

multipleOffsetDistances : IList<float>

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

?loop : bool

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

?checkOrientation : bool

bool, Optional(true). By default the algorithm always checks if the polyline is clockwise or counter clockwise. So that positive offset distances are always towards the inside of the polyline. Set this parameter to false if you are sure that the input polyline is counter clockwise or if you want to skip this check.

?varDistParallelBehavior : VarDistParallel

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

?uTurnBehavior : UTurn

Optional. Default value: `Offset2D.UTurnBehavior.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.

Polyline2D.pointCount p

Full Usage: Polyline2D.pointCount p

Parameters:
Returns: int
Modifiers: inline

Gets the number of points in the Polyline2D.

p : Polyline2D
Returns: int

Polyline2D.pointsUnsafeInternal p

Full Usage: Polyline2D.pointsUnsafeInternal p

Parameters:
Returns: ResizeArray<Pt>

Gets the internal list of all Points of the Polyline2D. This is not a copy, so changes to the list will be reflected in the Polyline2D.

p : Polyline2D
Returns: ResizeArray<Pt>

Polyline2D.removeColinearAndDuplicatePoints angleTolerance distanceTolerance pl

Full Usage: Polyline2D.removeColinearAndDuplicatePoints angleTolerance distanceTolerance pl

Parameters:
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.

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

Polyline2D.removeDuplicatePoints distanceTolerance pl

Full Usage: Polyline2D.removeDuplicatePoints distanceTolerance pl

Parameters:
Returns: Polyline2D

Removes consecutive duplicate points from the Polyline2D within a given tolerance. This algorithm allows the last and first point to be identical if the Polyline2D is closed.

distanceTolerance : float
pl : Polyline2D
Returns: Polyline2D

Polyline2D.reverse p

Full Usage: Polyline2D.reverse p

Parameters:
Returns: Polyline2D

Returns new Polyline2D in reversed Order.

p : Polyline2D
Returns: Polyline2D

Polyline2D.reverseInPlace p

Full Usage: Polyline2D.reverseInPlace p

Parameters:

Reverse order of the Polyline2D in place.

p : Polyline2D

Polyline2D.rotate r pl

Full Usage: Polyline2D.rotate r pl

Parameters:
Returns: Polyline2D

Rotation a Polyline2D around Z-Axis.

r : Rotation2D
pl : Polyline2D
Returns: Polyline2D

Polyline2D.rotateWithCenter cen r pl

Full Usage: Polyline2D.rotateWithCenter cen r pl

Parameters:
Returns: Polyline2D

Rotation a Polyline2D round given Center point an a local Z-axis.

cen : Pt
r : Rotation2D
pl : Polyline2D
Returns: Polyline2D

Polyline2D.scale factor pl

Full Usage: Polyline2D.scale factor pl

Parameters:
Returns: Polyline2D

Scales the Polyline2D by a given factor. Scale center is World Origin 0,0 Returns a new Polyline2D.

factor : float
pl : Polyline2D
Returns: Polyline2D

Polyline2D.segmentCount p

Full Usage: Polyline2D.segmentCount p

Parameters:
Returns: int
Modifiers: inline

Gets the number of segments in the Polyline2D.

p : Polyline2D
Returns: int

Polyline2D.start p

Full Usage: Polyline2D.start p

Parameters:
Returns: Pt

Gets first point of the Polyline2D

p : Polyline2D
Returns: Pt

Polyline2D.subPolyline a b pl

Full Usage: Polyline2D.subPolyline a b pl

Parameters:
Returns: Polyline2D

Returns new Polyline2D from point at Parameter a to point at Parameter b. if 'a' is bigger 'b' then the new Polyline2D is in opposite direction. If a parameter is within 1e-4 of an integer value, the integer value is used as parameter.

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

Polyline2D.translate v pl

Full Usage: Polyline2D.translate v pl

Parameters:
Returns: Polyline2D

Move a Polyline2D by a vector. (same as Polyline2D.move)

v : Vc
pl : Polyline2D
Returns: Polyline2D

Polyline2D.tryFindSelfIntersection pl

Full Usage: Polyline2D.tryFindSelfIntersection pl

Parameters:
Returns: Option<Pt * int * int>

Tries to find a self intersection in the Polyline2D. Also returns Some if segments are just touching. If found returns the intersection point and the indices of the two segments that intersect. If no intersection is found returns None. This is an O(n^2) algorithm and should only be used for small Polylines.

pl : Polyline2D
Returns: Option<Pt * int * int>

Polyline2D.windingNumber point pl

Full Usage: Polyline2D.windingNumber point pl

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

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

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

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

point : Pt

The point to test.

pl : Polyline2D

The closed Polyline2D.

Returns: int

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

Type something to start searching.