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
|
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.
|
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
|
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 .
|
|
|
|
Returns the distance of the test point to the closest point on the Polyline2D.
|
|
Creates a copy of the Polyline2D
|
Gets last or end point of the Polyline2D
|
|
|
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.IsAlmostClosed
Parameters:
float
Returns: bool
|
Tests if Polyline2D is closed within given tolerance.
|
Full Usage:
this.IsClosed
Returns: bool
Modifiers: inline |
Tests if Polyline2D start and end points are exactly the same.
|
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.Length
Returns: float
|
Gets the length of the Polyline2D
|
Full Usage:
this.PointCount
Returns: int
Modifiers: inline |
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. |
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.
|
|
Gets first point of the Polyline2D
|
|
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 .
|
Static members
Static member |
Description
|
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 form 0.0 to 1.0 on the segment. The domain Polyline2D starts at 0.0 and ends at point count.
|
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.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.
|
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.evaluateAt t pl
Parameters:
float
pl : Polyline2D
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.
|
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.
|
Full Usage:
Polyline2D.move v pl
Parameters:
Vc
pl : Polyline2D
Returns: Polyline2D
Modifiers: inline |
Move a Polyline2D by a vector. (same as Polyline2D.translate)
|
Full Usage:
Polyline2D.moveX distance pl
Parameters:
float
pl : Polyline2D
Returns: Polyline2D
Modifiers: inline |
Returns a Polyline2D moved by a given distance in X direction.
|
Full Usage:
Polyline2D.moveY distance pl
Parameters:
double
pl : Polyline2D
Returns: Polyline2D
Modifiers: inline |
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 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.
|
Full Usage:
Polyline2D.offset (polyLine, offsetDistances, ?loop, ?referenceOrient, ?obliqueOffsets)
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 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.
|
Full Usage:
Polyline2D.pointsUnsafeInternal p
Parameters:
Polyline2D
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.
|
|
|
|
Reverse order of the Polyline2D in place.
|
Full Usage:
Polyline2D.rotate r pl
Parameters:
Rotation2D
pl : Polyline2D
Returns: Polyline2D
Modifiers: inline |
|
Full Usage:
Polyline2D.rotateWithCenter cen r pl
Parameters:
Pt
r : Rotation2D
pl : Polyline2D
Returns: Polyline2D
Modifiers: inline |
Rotation a Polyline2D round given Center point an a local Z-axis.
|
Full Usage:
Polyline2D.segment 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.
|
|
|
Full Usage:
Polyline2D.translate v pl
Parameters:
Vc
pl : Polyline2D
Returns: Polyline2D
Modifiers: inline |