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.
-
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()
-
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>
-
Returns a list of line segments that represent the outlines of this line polygon. If this polygon contains < 2 vertices, the result is an empty array.
Declaration
Swift
@inlinable public func lineSegments() -> [LineSegment<Vector>]
-
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 }
-
Returns the closest point within the lines represented by
self
topoint
.If
self.vertices < 1
, the result ispoint
itself.Declaration
Swift
@inlinable func project(_ point: Vector) -> Vector