Show / Hide Table of Contents

    Class Polyline

    A continuous set of lines. Parameterization of the curve is 0->n-1 where n is the number of vertices.

    Examples
    var a = new Vector3();
    var b = new Vector3(10, 10);
    var c = new Vector3(20, 5);
    var d = new Vector3(25, 10);
    
    var pline = new Polyline(new[] { a, b, c, d });
    var offset = pline.Offset(1, EndType.Square);
    
    Inheritance
    System.Object
    Curve
    BoundedCurve
    IndexedPolycurve
    Polyline
    Polygon
    Implements
    ICurve
    ITransformable<Curve>
    IBoundedCurve
    System.Collections.Generic.IEnumerable<BoundedCurve>
    System.Collections.IEnumerable
    System.IEquatable<IndexedPolycurve>
    Inherited Members
    IndexedPolycurve.Start
    IndexedPolycurve.End
    IndexedPolycurve.CurveIndices
    IndexedPolycurve.Vertices
    IndexedPolycurve.Bounds()
    IndexedPolycurve.GetSubdivisionParameters(Double, Double)
    IndexedPolycurve.ArcLength(Double, Double)
    IndexedPolycurve.ParameterAtDistanceFromParameter(Double, Double)
    IndexedPolycurve.PointAt(Double)
    IndexedPolycurve.PointAtInternal(Double, Int32)
    IndexedPolycurve.TransformedPolycurve(Transform)
    IndexedPolycurve.Equals(IndexedPolycurve)
    IndexedPolycurve.ToString()
    IndexedPolycurve.ToPolygon()
    IndexedPolycurve.ValidateVertices()
    IndexedPolycurve.CheckCoincidenceAndThrow(IList<Vector3>)
    IndexedPolycurve.GetEnumerator()
    IndexedPolycurve.IEnumerable.GetEnumerator()
    BoundedCurve.DefaultMinimumChordLength
    BoundedCurve.Mid()
    BoundedCurve.IsClosedForRendering
    BoundedCurve.ToPolyline(Int32)
    BoundedCurve.PointAtNormalized(Double)
    BoundedCurve.TransformAtNormalized(Double)
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Elements.Geometry
    Assembly: Hypar.Elements.dll
    Syntax
    public class Polyline : IndexedPolycurve, ICurve, ITransformable<Curve>, IBoundedCurve, IEnumerable<BoundedCurve>, IEnumerable, IEquatable<IndexedPolycurve>

    Constructors

    Polyline(Vector3[])

    Construct a polyline from points. This is a convenience constructor that can be used like this: new Polyline((0,0,0), (10,0,0), (10,10,0))

    Declaration
    public Polyline(params Vector3[] vertices)
    Parameters
    Type Name Description
    Vector3[] vertices

    The vertices of the polyline.

    Polyline(Boolean, Vector3[])

    Construct a polyline from points. This is a convenience constructor that can be used like this: new Polyline((0,0,0), (10,0,0), (10,10,0))

    Declaration
    public Polyline(bool disableValidation, params Vector3[] vertices)
    Parameters
    Type Name Description
    System.Boolean disableValidation

    Should self intersection testing be disabled?

    Vector3[] vertices

    The vertices of the polyline.

    Polyline(IList<Vector3>)

    Construct a polyline.

    Declaration
    [JsonConstructor]
    public Polyline(IList<Vector3> vertices)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> vertices

    A collection of vertex locations.

    Polyline(IList<Vector3>, Boolean)

    Construct a polyline.

    Declaration
    public Polyline(IList<Vector3> vertices, bool disableValidation = false)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> vertices

    A collection of vertex locations.

    System.Boolean disableValidation

    Should self intersection testing be disabled?

    Properties

    Domain

    The domain of the curve.

    Declaration
    [JsonIgnore]
    public override Domain1d Domain { get; }
    Property Value
    Type Description
    Domain1d
    Overrides
    IndexedPolycurve.Domain

    Methods

    CreateMiterTransform(Int32, Vector3, Vector3)

    Generates a transform that expresses the plane of a miter join at a point on the curve.

    Declaration
    protected Transform CreateMiterTransform(int i, Vector3 a, Vector3 up)
    Parameters
    Type Name Description
    System.Int32 i
    Vector3 a
    Vector3 up
    Returns
    Type Description
    Transform

    Fillet(Double)

    Fillet all corners on this polygon.

    Declaration
    public IndexedPolycurve Fillet(double radius)
    Parameters
    Type Name Description
    System.Double radius

    The fillet radius.

    Returns
    Type Description
    IndexedPolycurve

    A contour containing trimmed edge segments and fillets.

    ForceAngleCompliance(IEnumerable<Double>, Vector3, NormalizationType)

    Make the polyline correspond to the supported angles by moving the vertices slightly. The result polyline will have only allowed angles, but vertices positions can be changed.

    Declaration
    public Polyline ForceAngleCompliance(IEnumerable<double> supportedAngles, Vector3 referenceVector, NormalizationType pathType = NormalizationType.Start)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<System.Double> supportedAngles

    List of supported angles that the returned polyline can have. Supported angles must be between 0 and 90.

    Vector3 referenceVector

    Vector to align first segment of polyline with.

    NormalizationType pathType

    The path type. For each 3 consecutive points A, B, C to make angle ABC be one of allowed angles:

    • NormalizationType.Start: move B vertex
    • NormalizationType.Middle: move both B and C vertices in approximately equivalent proportions
    • NormalizationType.End : move C vertex
    Returns
    Type Description
    Polyline

    The result polyline that has only allowed angles.

    ForceAngleCompliance(IEnumerable<Double>, Vector3, out Double, NormalizationType)

    Make the polyline correspond to the supported angles by moving the vertices slightly. The result polyline will have only allowed angles, but vertices positions can be changed. The first vertex is never moved.

    Declaration
    public Polyline ForceAngleCompliance(IEnumerable<double> supportedAngles, Vector3 referenceVector, out double furthestDistancePointsMoved, NormalizationType pathType = NormalizationType.Start)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<System.Double> supportedAngles

    List of supported angles that the returned polyline can have. Supported angles must be between 0 and 90.

    Vector3 referenceVector

    Vector to align first segment of polyline with.

    System.Double furthestDistancePointsMoved

    The furthest distance that any point moved.

    NormalizationType pathType

    The path type. For each 3 consecutive points A, B, C to make angle ABC be one of allowed angles:

    • NormalizationType.Start: move B vertex
    • NormalizationType.Middle: move both B and C vertices in approximately equivalent proportions
    • NormalizationType.End : move C vertex
    Returns
    Type Description
    Polyline

    The result polyline that has only allowed angles.

    Frames(Double, Double, Double)

    Get a collection of Transforms which represent frames along this curve.

    Declaration
    public override Transform[] Frames(double startSetbackDistance = 0, double endSetbackDistance = 0, double additionalRotation = 0)
    Parameters
    Type Name Description
    System.Double startSetbackDistance

    The offset from the start of the ICurve.

    System.Double endSetbackDistance

    The offset from the end of the ICurve.

    System.Double additionalRotation

    An additional rotation of the frame at each point.

    Returns
    Type Description
    Transform[]

    A collection of Transforms.

    Overrides
    BoundedCurve.Frames(Double, Double, Double)

    GetParameterAt(Vector3)

    Find the parameter corresponding to a point along a polyline.

    Declaration
    public double GetParameterAt(Vector3 point)
    Parameters
    Type Name Description
    Vector3 point

    A point.

    Returns
    Type Description
    System.Double

    A parameter for the point along a polyline if the point is on the polyline. Otherwise, -1.

    GetSubsegment(Vector3, Vector3)

    Get new polyline between two points

    Declaration
    public Polyline GetSubsegment(Vector3 start, Vector3 end)
    Parameters
    Type Name Description
    Vector3 start

    Start point

    Vector3 end

    End point

    Returns
    Type Description
    Polyline

    New polyline or null if any of points is not on polyline

    Intersects(Line, out List<Vector3>, Boolean, Boolean)

    Check if polyline intersects with line

    Declaration
    public bool Intersects(Line line, out List<Vector3> intersections, bool infinite = false, bool includeEnds = false)
    Parameters
    Type Name Description
    Line line

    Line to check

    System.Collections.Generic.List<Vector3> intersections

    Intersections between polyline and line

    System.Boolean infinite

    Threat the line as infinite?

    System.Boolean includeEnds

    If the end of line lies exactly on the vertex of polyline, count it as an intersection?

    Returns
    Type Description
    System.Boolean

    True if line intersects with polyline, false if they do not intersect

    Intersects(Polygon, out List<Polyline>)

    Checks if polyline intersects with polygon

    Declaration
    public bool Intersects(Polygon polygon, out List<Polyline> sharedSegments)
    Parameters
    Type Name Description
    Polygon polygon

    Polygon to check

    System.Collections.Generic.List<Polyline> sharedSegments

    List of shared subsegments

    Returns
    Type Description
    System.Boolean

    Result of check if polyline and polygon intersects

    Length()

    Calculate the length of the polygon.

    Declaration
    public override double Length()
    Returns
    Type Description
    System.Double
    Overrides
    IndexedPolycurve.Length()

    NormalsAtVertices()

    Get the normal of each vertex on the polyline.

    Declaration
    protected virtual Vector3[] NormalsAtVertices()
    Returns
    Type Description
    Vector3[]

    A collection of unit vectors, each corresponding to a single vertex.

    Offset(Double, EndType, Double)

    Offset this polyline by the specified amount.

    Declaration
    public virtual Polygon[] Offset(double offset, EndType endType, double tolerance = 1E-05)
    Parameters
    Type Name Description
    System.Double offset

    The amount to offset.

    EndType endType

    The closure type to use on the offset polygon.

    System.Double tolerance

    An optional tolerance.

    Returns
    Type Description
    Polygon[]

    A new closed Polygon offset in all directions by offset from the polyline.

    OffsetOnSide(Double, Boolean)

    Offset this polyline by the specified amount, only on one side.

    Declaration
    public Polygon[] OffsetOnSide(double offset, bool flip)
    Parameters
    Type Name Description
    System.Double offset

    The amount to offset.

    System.Boolean flip

    Offset on the opposite of the default side. The default is to draw on the +X side of a polyline that goes up the +Y axis.

    Returns
    Type Description
    Polygon[]

    An array of polygons that are extruded from each segment of the polyline.

    Remarks

    This blunts sharp corners to keep widths close to the target.

    OffsetOpen(Double)

    A naïve control-point-only 2D open offset. This algorithm does not do any self-intersection checking.

    Declaration
    public Polyline OffsetOpen(double offset)
    Parameters
    Type Name Description
    System.Double offset

    The offset distance.

    Returns
    Type Description
    Polyline

    A new polyline with the same number of control points.

    OffsetWithAcuteAngle(Double)

    Offset this polyline by the specified amount. The resulting polygon will have acute angles.

    Declaration
    public Polygon[] OffsetWithAcuteAngle(double offset)
    Parameters
    Type Name Description
    System.Double offset

    The amount to offset.

    Returns
    Type Description
    Polygon[]
    Remarks

    This blunts sharp corners to keep widths close to the target.

    Plane()

    Compute the Plane defined by the first three non-collinear vertices of the Polygon.

    Declaration
    public virtual Plane Plane()
    Returns
    Type Description
    Plane

    A Plane.

    Project(Plane)

    Project this polyline onto the plane.

    Declaration
    public Polyline Project(Plane plane)
    Parameters
    Type Name Description
    Plane plane

    The plane of the returned polyline.

    Returns
    Type Description
    Polyline

    Reversed()

    Reverse the direction of a polyline.

    Declaration
    public Polyline Reversed()
    Returns
    Type Description
    Polyline

    Returns a new polyline with opposite winding.

    Segments()

    Get a collection a line segments which connect the vertices of this polyline.

    Declaration
    public virtual Line[] Segments()
    Returns
    Type Description
    Line[]

    A collection of Lines.

    SharedSegments(Polyline, Polyline, Boolean)

    Identify any shared segments between two polylines.

    Declaration
    public static List<(int indexOnA, int indexOnB)> SharedSegments(Polyline a, Polyline b, bool isClosed = false)
    Parameters
    Type Name Description
    Polyline a

    The first polyline to compare.

    Polyline b

    The second polyline to compare.

    System.Boolean isClosed

    Flag as closed to include segment between first and last vertex.

    Returns
    Type Description
    System.Collections.Generic.List<System.ValueTuple<System.Int32, System.Int32>>

    Returns a list of tuples of indices for the segments that match in each polyline.

    Split(IList<Vector3>)

    Insert a point into the polyline if it lies along one of the polyline's segments.

    Declaration
    public virtual void Split(IList<Vector3> points)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> points

    The points at which to split the polyline.

    Split(IList<Vector3>, Boolean)

    Insert a point into the polyline if it lies along one of the polyline's segments.

    Declaration
    protected void Split(IList<Vector3> points, bool closed = false)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> points

    The points at which to split the polyline.

    System.Boolean closed

    Is the polyline closed?

    TransformAt(Double)

    Get the transform at the specified parameter along the polyline.

    Declaration
    public override Transform TransformAt(double u)
    Parameters
    Type Name Description
    System.Double u

    The parameter on the polygon between 0.0 and length.

    Returns
    Type Description
    Transform

    A transform with its Z axis aligned trangent to the polyline.

    Overrides
    IndexedPolycurve.TransformAt(Double)

    Transformed(Transform)

    Create a transformed copy of this curve. Use of non-affine transforms (i.e. scale) will result in unpredictable results for curve methods such as Length().

    Declaration
    public override Curve Transformed(Transform transform)
    Parameters
    Type Name Description
    Transform transform

    The transform to apply.

    Returns
    Type Description
    Curve
    Overrides
    IndexedPolycurve.Transformed(Transform)

    TransformedPolyline(Transform)

    Construct a transformed copy of this Polyline.

    Declaration
    public Polyline TransformedPolyline(Transform transform)
    Parameters
    Type Name Description
    Transform transform

    The transform to apply.

    Returns
    Type Description
    Polyline

    TransformSegment(Transform, Int32, Boolean, Boolean)

    Transform a specified segment of this polyline in place.

    Declaration
    public void TransformSegment(Transform t, int i, bool isClosed = false, bool isPlanar = false)
    Parameters
    Type Name Description
    Transform t

    The transform. If it is not within the polygon plane, then an exception will be thrown.

    System.Int32 i

    The segment to transform. If it does not exist, then no work will be done.

    System.Boolean isClosed

    If set to true, the segment between the start end end point will be considered a valid target.

    System.Boolean isPlanar

    If set to true, an exception will be thrown if the resultant shape is no longer planar.

    Implements

    ICurve
    ITransformable<T>
    IBoundedCurve
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    System.IEquatable<T>