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
|
|
Create a new empty Polyline2D with predefined capacity for the internal list of points.
|
|
Create a new empty Polyline2D
|
|
|
Instance members
Instance member |
Description
|
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.
|
|
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.CloseIfOpen
Parameters:
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.
|
|
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 .
|
|
|
|
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.
|
|
Returns the distance of the test point to the closest point on the Polyline2D.
|
|
Creates a copy of the Polyline2D Same as polyline.Clone()
|
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 |
|
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.
|
Full Usage:
this.FirstPoint
|
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.
|
|
|
Full Usage:
this.IsAlmostClosed
Parameters:
float
Returns: bool
|
Tests if Polyline2D is closed within given tolerance. Fails if the Polyline3D 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. Fails if the Polyline3D 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.
|
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 |
Full Usage:
this.LastPointIndex
Returns: int
|
Gets the index of the last point in the Polyline2D. points.Count - 1
|
|
Gets the segment at index i of the Polyline2D.
|
Full Usage:
this.LastSegmentIndex
Returns: int
|
Gets the index of the last segment in the Polyline2D. This is poly.Points.Count - 2
|
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
|
|
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 new Polyline2D in reversed Order.
|
Full Usage:
this.ReverseInPlace
|
Reverse order of the Polyline2D in place. |
|
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
|
Full Usage:
this.SecondLastPoint
|
Gets or sets the second last point of the Polyline2D. |
Full Usage:
this.SecondPoint
|
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 all segments of the Polyline2D as a list of Line2D.
|
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.
|
Full Usage:
this.Start
|
Gets or sets first point of the Polyline2D This is the point at index 0. Same as Polyline2D.FirstPoint |
|
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 .
|
|
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
|
Static members
Static member |
Description
|
|
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.
|
|
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.
|
|
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.
|
|
Returns the point on the Polyline2D that is the closest point to the given point.
|
|
|
Full Usage:
Polyline2D.createDirectlyUnsafe points
Parameters:
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.
|
|
Create a new empty Polyline2D without any points. But predefined capacity.
|
|
Returns the distance of the test point to the closest point on the Polyline2D.
|
|
|
Full Usage:
Polyline2D.equals tol a b
Parameters:
float
a : Polyline2D
b : Polyline2D
Returns: bool
|
Tests if two Polyline2D have the same number of points and 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 form 0.0 to 1.0 on the segment. The domain Polyline2D starts at 0.0 and ends at point count.
|
Full Usage:
Polyline2D.map mapping pl
Parameters:
Pt -> Pt
pl : Polyline2D
Returns: Polyline2D
|
Apply a mapping function to each point in the 2D Polyline2D. 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, offsetDistance, ?loop, ?referenceOrient)
Parameters:
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.
|
Full Usage:
Polyline2D.offset (polyLine, offsetDistances, ?loop, ?referenceOrient)
Parameters:
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.
|
|
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.
|
|
|
|
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.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 '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.
|
|