ClosedShape2Intersection

public enum ClosedShape2Intersection<Vector> where Vector : Vector2FloatingPoint
extension ClosedShape2Intersection: Equatable where Vector: Equatable
extension ClosedShape2Intersection: Hashable where Vector: Hashable

The result of a intersection test against two 2-dimensional closed shapes.

  • Represents the case where the shape’s boundaries are completely contained within the bounds of the other shape.

    Declaration

    Swift

    case contained
  • Represents the case where the other shape’s boundaries are completely contained within the bounds of the first shape.

    Is the diametrical opposite of .contained.

    Declaration

    Swift

    case contains
  • Represents the case where the shape crosses the bounds of the shape on a single vertex, or tangentially, in case of spheroids.

    Declaration

    Swift

    case singlePoint(PointNormal<Vector>)
  • A sequence of one or more intersection pairs of points that represent the entrance and exit points of the intersection in relation to one of the shapes.

    Declaration

    Swift

    case pairs([Pair])
  • Represents the case where no intersection occurs at any point.

    Declaration

    Swift

    case noIntersection
  • Returns all the point normals associated with this closed shape intersection object.

    Declaration

    Swift

    public var pointNormals: [PointNormal<Vector>] { get }
  • Convenience for .pairs([.init(enter: p1, exit: p2)]).

    Declaration

    Swift

    @inlinable
    public static func twoPoints(
        _ p1: PointNormal<Vector>,
        _ p2: PointNormal<Vector>
    ) -> Self
  • Returns a new ClosedShape2Intersection where any PointNormal value is mapped by a provided closure before being stored back into the same enum case and returned.

    Declaration

    Swift

    public func mappingPointNormals(
        _ mapper: (PointNormal<Vector>, LineIntersectionPointNormalKind) -> PointNormal<Vector>
    ) -> Self
  • Returns a new ClosedShape2Intersection where any PointNormal value is replaced by a provided closure before being stored back into the same enum case and returned.

    Declaration

    Swift

    public func replacingPointNormals<NewVector: VectorType>(
        _ mapper: (PointNormal<Vector>, LineIntersectionPointNormalKind) -> PointNormal<NewVector>
    ) -> ClosedShape2Intersection<NewVector>
  • A pair of entrance/exit intersection points.

    The definition of entrance/exit is dependant on the shapes intersected, and the only requirement is that within the same ClosedShape2Intersection, each pair is expected to be connectable entrance-to-exit with its succeeding pair.

    See more

    Declaration

    Swift

    public struct Pair
    extension ClosedShape2Intersection.Pair: Equatable where Vector: Equatable
    extension ClosedShape2Intersection.Pair: Hashable where Vector: Hashable
  • Parameter passed along point normals in mappingPointNormals(_:) and replacingPointNormals(_:) to specify to the closure which kind of point normal was provided.

    See more

    Declaration

    Swift

    public enum LineIntersectionPointNormalKind