Header menu logo Euclid

Polyline2D Type

A mutable 2D Polyline. If the last point is the same as the first point, the Polyline2D is considered closed.

Record fields

Record Field Description

Points

Full Usage: Points

Field type: 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.

Field type: ResizeArray<Pt>

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.BoundingRectangle

Full Usage: this.BoundingRectangle

Returns: BRect

Gets bounding rectangle of the Polyline2D

Returns: BRect

this.CloseIfOpen

Full Usage: this.CloseIfOpen

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 .

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

pt : Pt
Returns: Pt

this.DistanceTo

Full Usage: this.DistanceTo

Parameters:
Returns: float

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

pt : Pt
Returns: float

this.Duplicate

Full Usage: this.Duplicate

Returns: Polyline2D
Modifiers: inline

Creates a copy of the Polyline2D

Returns: Polyline2D

this.End

Full Usage: this.End

Returns: Pt

Gets last or end point of the Polyline2D

Returns: Pt

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.IsAlmostClosed

Full Usage: this.IsAlmostClosed

Parameters:
    tolerance : float

Returns: bool

Tests if Polyline2D is closed within given tolerance.

tolerance : float
Returns: bool

this.IsClosed

Full Usage: this.IsClosed

Returns: bool
Modifiers: inline

Tests if Polyline2D start and end points are exactly the same.

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.Length

Full Usage: this.Length

Returns: float

Gets the length of the Polyline2D

Returns: float

this.PointCount

Full Usage: this.PointCount

Returns: int
Modifiers: inline

Gets the count of points in the Polyline2D

Returns: int

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.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.Start

Full Usage: this.Start

Returns: Pt

Gets first point of the Polyline2D

Returns: Pt

this.TangentAt

Full Usage: this.TangentAt

Parameters:
    t : float

Returns: UnitVc

Returns the Unitized Tangent 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 .

t : float
Returns: UnitVc

Static members

Static member Description

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.create points

Full Usage: Polyline2D.create points

Parameters:
    points : Pt seq

Returns: Polyline2D

Create a new Polyline2D by copying over 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. 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

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
Modifiers: inline

Gets last or end point of the Polyline2D

p : Polyline2D
Returns: Pt

Polyline2D.evaluateAt t pl

Full Usage: Polyline2D.evaluateAt t pl

Parameters:
Returns: Pt
Modifiers: inline

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.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
Modifiers: inline

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
Modifiers: inline

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
Modifiers: inline

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

distance : double
pl : Polyline2D
Returns: Polyline2D

Polyline2D.offset (polyLine, offsetDistance, ?loop, ?referenceOrient)

Full Usage: Polyline2D.offset (polyLine, offsetDistance, ?loop, ?referenceOrient)

Parameters:
    polyLine : Polyline2D - A 2D Polyline.
    offsetDistance : float - The offset distance for all segments of the polyline. A positive distance offsets inwards in corners, a negative offset outwards.
    ?loop : bool - Consider last point and first point to be from a closed loop, even if they are not at the same location.
    ?referenceOrient : float - float, Optional. This is to control on which side of the polyline the offset is created. By default the offset is created to the inside of the polygon / polyline. The algorithm tries to detect if the loop is clockwise or counterclockwise. But this cannot always be detected. For example on self intersecting polylines. If 'referenceOrient' is bigger than 0.0 a counterclockwise loops is assumed and the detection part is skipped. If 'referenceOrient' is smaller than 0.0 a clockwise loops is assumed and the detection part is skipped. The 'referenceOrient' corresponds to the Cross Product of two segment of the polyline an an convex corner. If 'referenceOrient' is 0.0 or omitted then the algorithm tries to detect if the loop is clockwise or counterclockwise. It also tries to find a convex corner on a convex and concave polyline. If the given referenceOrient does not correspond to the looping order the offset will be to the other side.

Returns: Polyline2D A new 2D polyline with the same amount of points.

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. Does not fail on colinear or duplicate points.

polyLine : Polyline2D

A 2D Polyline.

offsetDistance : float

The offset distance for all segments of the polyline. A positive distance offsets inwards in corners, a negative offset outwards.

?loop : bool

Consider last point and first point to be from a closed loop, even if they are not at the same location.

?referenceOrient : float

float, Optional. This is to control on which side of the polyline the offset is created. By default the offset is created to the inside of the polygon / polyline. The algorithm tries to detect if the loop is clockwise or counterclockwise. But this cannot always be detected. For example on self intersecting polylines. If 'referenceOrient' is bigger than 0.0 a counterclockwise loops is assumed and the detection part is skipped. If 'referenceOrient' is smaller than 0.0 a clockwise loops is assumed and the detection part is skipped. The 'referenceOrient' corresponds to the Cross Product of two segment of the polyline an an convex corner. If 'referenceOrient' is 0.0 or omitted then the algorithm tries to detect if the loop is clockwise or counterclockwise. It also tries to find a convex corner on a convex and concave polyline. If the given referenceOrient does not correspond to the looping order the offset will be to the other side.

Returns: Polyline2D

A new 2D polyline with the same amount of points.

Polyline2D.offset (polyLine, offsetDistances, ?loop, ?referenceOrient, ?obliqueOffsets)

Full Usage: Polyline2D.offset (polyLine, offsetDistances, ?loop, ?referenceOrient, ?obliqueOffsets)

Parameters:
    polyLine : Polyline2D - A 2D Polyline.
    offsetDistances : 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. A singleton for constant offset is allowed too.
    ?loop : bool - bool, Optional. Consider last point and first point to be from a closed loop, even if they are not at the same location.
    ?referenceOrient : float - float, Optional. This is to control on which side of the polyline the offset is created. By default the offset is created to the inside of the polygon / polyline. The algorithm tries to detect if the loop is clockwise or counterclockwise. But this cannot always be detected. For example on self intersecting polylines. If 'referenceOrient' is bigger than 0.0 a counterclockwise loops is assumed and the detection part is skipped. If 'referenceOrient' is smaller than 0.0 a clockwise loops is assumed and the detection part is skipped. The 'referenceOrient' corresponds to the Cross Product of two segment of the polyline an an convex corner. If 'referenceOrient' is 0.0 or omitted then the algorithm tries to detect if the loop is clockwise or counterclockwise. It also tries to find a convex corner on a convex and concave polyline. If the given referenceOrient does not correspond to the looping order the offset will be to the other side.
    ?obliqueOffsets : bool - bool, Optional. When two adjacent segments are colinear but have different offset distances there is no solution with a parallel offset. By default an exception is raised. Set this to true to create and averaged oblique offset instead of failing.

Returns: Polyline2D A new 2D polyline with the same amount of points.

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. Does not fail on colinear or duplicate points.

polyLine : Polyline2D

A 2D Polyline.

offsetDistances : 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. A singleton for constant offset is allowed too.

?loop : bool

bool, Optional. Consider last point and first point to be from a closed loop, even if they are not at the same location.

?referenceOrient : float

float, Optional. This is to control on which side of the polyline the offset is created. By default the offset is created to the inside of the polygon / polyline. The algorithm tries to detect if the loop is clockwise or counterclockwise. But this cannot always be detected. For example on self intersecting polylines. If 'referenceOrient' is bigger than 0.0 a counterclockwise loops is assumed and the detection part is skipped. If 'referenceOrient' is smaller than 0.0 a clockwise loops is assumed and the detection part is skipped. The 'referenceOrient' corresponds to the Cross Product of two segment of the polyline an an convex corner. If 'referenceOrient' is 0.0 or omitted then the algorithm tries to detect if the loop is clockwise or counterclockwise. It also tries to find a convex corner on a convex and concave polyline. If the given referenceOrient does not correspond to the looping order the offset will be to the other side.

?obliqueOffsets : bool

bool, Optional. When two adjacent segments are colinear but have different offset distances there is no solution with a parallel offset. By default an exception is raised. Set this to true to create and averaged oblique offset instead of failing.

Returns: Polyline2D

A new 2D polyline with the same amount of points.

Polyline2D.pointsUnsafeInternal p

Full Usage: Polyline2D.pointsUnsafeInternal p

Parameters:
Returns: ResizeArray<Pt>
Modifiers: inline

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.reverse p

Full Usage: Polyline2D.reverse p

Parameters:
Returns: Polyline2D
Modifiers: inline

Returns new Polyline2D in reversed Order.

p : Polyline2D
Returns: Polyline2D

Polyline2D.reverseInPlace p

Full Usage: Polyline2D.reverseInPlace p

Parameters:
Modifiers: inline

Reverse order of the Polyline2D in place.

p : Polyline2D

Polyline2D.rotate r pl

Full Usage: Polyline2D.rotate r pl

Parameters:
Returns: Polyline2D
Modifiers: inline

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
Modifiers: inline

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

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

Polyline2D.segment a b pl

Full Usage: Polyline2D.segment 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.start p

Full Usage: Polyline2D.start p

Parameters:
Returns: Pt
Modifiers: inline

Gets first point of the Polyline2D

p : Polyline2D
Returns: Pt

Polyline2D.translate v pl

Full Usage: Polyline2D.translate v pl

Parameters:
Returns: Polyline2D
Modifiers: inline

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

v : Vc
pl : Polyline2D
Returns: Polyline2D

Type something to start searching.