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.

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

Full Usage: this.Contains

Parameters:
    point : Pt

Returns: bool

The first and last point of the Polyline2D need to be identical for correct results Uses the WindingNumber to determine if the point is inside the Polyline2D.

point : Pt
Returns: bool

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

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.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. Fails if the Polyline3D 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. Fails if the Polyline3D 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.Segments

Full Usage: this.Segments

Returns: ResizeArray<Line2D>

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

Returns: ResizeArray<Line2D>

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

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

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

this.WindingNumber

Full Usage: this.WindingNumber

Parameters:
    point : Pt

Returns: int

If it is 0 then point is outside of the Loop The first and last point of the Polyline2D need to be identical for correct results

point : Pt
Returns: int

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

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

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

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.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, 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 loop is assumed and the detection part is skipped. If 'referenceOrient' is smaller than 0.0 a clockwise loop 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 loop is assumed and the detection part is skipped. If 'referenceOrient' is smaller than 0.0 a clockwise loop 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)

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

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 loop is assumed and the detection part is skipped. If 'referenceOrient' is smaller than 0.0 a clockwise loop 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.

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 loop is assumed and the detection part is skipped. If 'referenceOrient' is smaller than 0.0 a clockwise loop 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.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.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.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

Type something to start searching.