LinePolygon

public struct LinePolygon<Vector> : GeometricType where Vector : VectorType
extension LinePolygon: Equatable where Vector: Equatable, Scalar: Equatable
extension LinePolygon: Hashable where Vector: Hashable, Scalar: Hashable
extension LinePolygon: Encodable where Vector: Encodable, Scalar: Encodable
extension LinePolygon: Decodable where Vector: Decodable, Scalar: Decodable
extension LinePolygon: BoundableType where Vector: VectorAdditive & VectorComparable

Represents a line polygon as a series of connected N-dimensional vertices.

A 2-dimensional line polygon defines a closed polygon, while in higher dimensions it is simply a list of line segments where the ends meet at the vertices.

  • Undocumented

    Declaration

    Swift

    public typealias Scalar = Vector.Scalar
  • A sequence of vertices that describe sequential lines connected at the end points.

    Declaration

    Swift

    public var vertices: [Vector]
  • Initializes a LinePolygon with empty vertices list.

    Declaration

    Swift

    public init()
  • Undocumented

    Declaration

    Swift

    public init(vertices: [Vector])
  • Adds a new vertex at the end of this polygon’s vertices list.

    Declaration

    Swift

    public mutating func addVertex(_ v: Vector)
  • Reverses the order of the vertices within this line polygon.

    Declaration

    Swift

    @inlinable
    public mutating func reverse()
  • Returns a new line polygon where the vertices are the reversed list of vertices from this line polygon.

    Declaration

    Swift

    @inlinable
    public func reversed() -> LinePolygon<Vector>

Available where Vector: VectorAdditive & VectorComparable

  • Returns the minimal AABB capable of containing all points from this line polygon.

    If vertices is empty, a zero AABB is returned, instead.

    Declaration

    Swift

    @inlinable
    public var bounds: AABB<Vector> { get }

Available where Vector: VectorFloatingPoint

  • Returns a vector with the coordinates of the arithmetic mean of all vectors in vertices.

    If the vertices array is empty, Vector.zero is returned, instead.

    Declaration

    Swift

    @inlinable
    var average: Vector { get }