Polygon

public struct Polygon : PolygonProtocol
extension Polygon: Additive
extension Polygon: Equatable
extension Polygon: CustomStringConvertible

Polgonal shape containing at least three vertices.

  • Note

    In the case that this Polygon is convex, the ConvexPolygonContainer is initialized with it. In the case the this Polygon is concave, it is broken up into the minimum number of triangles through an Ear Clipping method.

    Declaration

    Swift

    public var collisionDetectable: ConvexPolygonContainer { get }

    Return Value

    ConvexPolygonContainer that can be used for collision detection.

  • Declaration

    Swift

    public var convexHull: Polygon { get }

    Return Value

    Convex hull of vertices in Polygon.

  • Vertices contained herein.

    Declaration

    Swift

    public let vertices: VertexCollection

Initializers

  • Creates a Polygon with the given vertices.

    Declaration

    Swift

    public init<S>(vertices: S) where S : Sequence, S.Element == Point
  • Create a unconstrained Polygon from any PolygonProtocol-conforming type.

    Declaration

    Swift

    public init(_ polygon: PolygonProtocol)
  • Empty polygon.

    Declaration

    Swift

    public static let zero: Polygon
  • Creates union of two given Polygon values.

    Declaration

    Swift

    public static func + (lhs: Polygon, rhs: Polygon) -> Polygon

CustomStringConvertible

  • Print the vertices in order of their appearance

    Declaration

    Swift

    public var description: String { get }